Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion failed: orphan parameter reference during pickling #21558

Closed
theosotr opened this issue Sep 6, 2024 · 2 comments · Fixed by #21824
Closed

assertion failed: orphan parameter reference during pickling #21558

theosotr opened this issue Sep 6, 2024 · 2 comments · Fixed by #21824

Comments

@theosotr
Copy link

theosotr commented Sep 6, 2024

Compiler version

3.5.0

Minimized code

class Base
class A[T <: Float](val f: T) extends Base

def test() = {
  m1(new A(m2()));

}

def m1(x: Base) = {}
def m2(p: A[? <: Float] = new A(1.0f)): Int = 1

Output (click arrow to expand)

Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(T)
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:311)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:177)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:699)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:345)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:517)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:517)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:509)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$2(TreePickler.scala:510)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:510)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:554)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:349)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:383)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:645)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:416)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:416)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:681)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:374)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:647)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:416)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:416)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:697)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:922)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:920)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:306)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:279)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:278)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:380)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:373)
	at dotty.tools.dotc.transform.Pickler.runPhase$1(Pickler.scala:392)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:398)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
	at dotty.tools.dotc.Run.compileSources(Run.scala:282)
	at dotty.tools.dotc.Run.compile(Run.scala:267)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
	at dotty.tools.dotc.Driver.process(Driver.scala:201)
	at dotty.tools.dotc.Driver.process(Driver.scala:169)
	at dotty.tools.dotc.Driver.process(Driver.scala:181)
	at dotty.tools.dotc.Driver.main(Driver.scala:211)
	at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
	at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
	at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)
@theosotr theosotr added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 6, 2024
@Gedochao Gedochao added area:pickling and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 10, 2024
@Gedochao
Copy link
Contributor

Full crash output:

error when pickling type T
error when pickling tree T
error when pickling tree new A[T]
error when pickling tree new A[T](Int.int2float(m2(repro$package.m2$default$1)))
error when pickling tree m1(new A[T](Int.int2float(m2(repro$package.m2$default$1))))
error when pickling tree {
  m1(new A[T](Int.int2float(m2(repro$package.m2$default$1))))
}
error when pickling tree def test(): Unit =
  {
    m1(new A[T](Int.int2float(m2(repro$package.m2$default$1))))
  }
error when pickling tree () extends Object() { this: repro$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[repro$package.type])
  def test(): Unit =
    {
      m1(new A[T](Int.int2float(m2(repro$package.m2$default$1))))
    }
  def m1(x: Base): Unit =
    {
      ()
    }
  def m2(p: A[? >: Nothing <: Float]): Int = 1
  def m2$default$1: A[? <: Float] @uncheckedVariance = new A[T](1.0f)
}
error when pickling tree @SourceFile("repro.scala") final module class repro$package() extends Object() {
   this: repro$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[repro$package.type])
  def test(): Unit =
    {
      m1(new A[T](Int.int2float(m2(repro$package.m2$default$1))))
    }
  def m1(x: Base): Unit =
    {
      ()
    }
  def m2(p: A[? >: Nothing <: Float]): Int = 1
  def m2$default$1: A[? <: Float] @uncheckedVariance = new A[T](1.0f)
}
error when pickling tree package <empty> {
  final lazy module val repro$package: repro$package = new repro$package()
  @SourceFile("repro.scala") final module class repro$package() extends Object()
     { this: repro$package.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[repro$package.type])
    def test(): Unit =
      {
        m1(new A[T](Int.int2float(m2(repro$package.m2$default$1))))
      }
    def m1(x: Base): Unit =
      {
        ()
      }
    def m2(p: A[? >: Nothing <: Float]): Int = 1
    def m2$default$1: A[? <: Float] @uncheckedVariance = new A[T](1.0f)
  }
}

  unhandled exception while running pickler on /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro/repro.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.

     while compiling: /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro/repro.scala
        during phase: pickler
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.0
            settings: -classpath /Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.0/scala3-library_3-3.5.0.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar -d /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro/.scala-build/compiler-repro_473cbde4c4-d9eb8ef26f/classes/main -sourceroot /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro

Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(T)
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:311)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:177)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:699)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:345)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:517)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:517)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:509)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$2(TreePickler.scala:510)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:510)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:554)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:349)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:383)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:645)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:416)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:416)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:681)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:374)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:647)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:416)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:416)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:697)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:922)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:920)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:306)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:279)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:278)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:380)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:373)
        at dotty.tools.dotc.transform.Pickler.runPhase$1(Pickler.scala:392)
        at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:398)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
        at dotty.tools.dotc.Run.compileSources(Run.scala:282)
        at dotty.tools.dotc.Run.compile(Run.scala:267)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)

Reproduced on 3.3.3, 3.5.0, 3.6.0-RC1-bin-20240907-614170f-NIGHTLY-git-614170f

@mbovel
Copy link
Member

mbovel commented Oct 20, 2024

This issue was picked for the Scala Issue Spree of tomorrow, Monday, October 21st. @dwijnand and @HarrisL2 will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants