Skip to content

Transparent inline codes causing compiler assertion error during pickling tree phase #18151

@ngsksy

Description

@ngsksy

Compiler version

3.3.0

Minimized code

in core/Tmpl.scala

import scala.compiletime.*
import scala.compiletime.ops.any.ToString

trait Attr
case object EmptyAttr extends Attr
transparent inline def attrStr(inline a: Attr): String = inline a match
  case EmptyAttr => ""
transparent inline def attrStrHelper(inline a: Attr): String = inline a match
  case EmptyAttr => ""
trait TmplNode
case class El[T <: String & Singleton, A <: Attr, C <: Tmpl](val tag: T, val attr: A, val child: C)
    extends TmplNode
case class Sib[L <: Tmpl, R <: Tmpl](left: L, right: R) extends TmplNode
type TmplSingleton = String | Char | Int | Long | Float | Double | Boolean
type Tmpl = TmplNode | Unit | (TmplSingleton & Singleton)
transparent inline def tmplStr(inline t: Tmpl): String = inline t match
  case El(tag, attr, child) => inline attrStr(attr) match
      case "" => "<" + tag + ">" + tmplStr(child)
      case x  => "<" + tag + " " + x + ">" + tmplStr(child)
  case Sib(left, right) => inline tmplStr(right) match
      case ""    => tmplStr(left)
      case right => tmplStrHelper(left) + right
  case ()                     => ""
  case s: (t & TmplSingleton) => constValue[ToString[t]]
transparent inline def tmplStrHelper(inline t: Tmpl): String = inline t match
  case El(tag, attr, child) => inline (tmplStr(child), attrStr(attr)) match
      case ("", "")      => "<" + tag + "/>"
      case (child, "")   => "<" + tag + ">" + child + "</" + tag + ">"
      case ("", attr)    => "<" + tag + " " + attr + "/>"
      case (child, attr) => "<" + tag + " " + attr + ">" + child + "</" + tag + ">"
  case Sib(left, right)       => tmplStrHelper(left) + tmplStrHelper(right)
  case ()                     => ""
  case s: (t & TmplSingleton) => constValue[ToString[t]]
transparent inline def el(tag: String & Singleton): El[tag.type, EmptyAttr.type, Unit] =
  El(tag, EmptyAttr, ())
extension [T <: String & Singleton, A <: Attr, C <: Tmpl](el: El[T, A, C])
  transparent inline def >>[C2 <: Tmpl](child: C2) = El(el.tag, el.attr, el.child ++ child)

extension [L <: Tmpl](left: L) transparent inline def ++[R <: Tmpl](right: R) = Sib(left, right)

in Main.scala

@main
def hello: Unit =
  println(tmplStr(el("div") >> "hello world"))

Output (click arrow to expand)

error when pickling tree val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
  core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
    core.EmptyAttr, ())
error when pickling tree {
  val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
    core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
      core.EmptyAttr, ())
  core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child, "hello world")
  }
error when pickling tree val $proxy3: core.Sib[Unit, ("hello world" : String)] =
  {
    val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
      core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
        core.EmptyAttr, ())
    core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
      "hello world")
  }
error when pickling tree {
  val tag: ("div" : String) = "div"
  val $proxy2: core.EmptyAttr.type =
    {
      val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
        core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
          core.EmptyAttr, ())
      el$proxy1.attr:core.EmptyAttr.type
    }
  val attr: core.EmptyAttr.type = $proxy2
  val $proxy3: core.Sib[Unit, ("hello world" : String)] =
    {
      val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
        core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
          core.EmptyAttr, ())
      core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
        "hello world")
    }
  val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
  "<div>hello world"
}
error when pickling tree {
  val tag: ("div" : String) = "div"
  val $proxy2: core.EmptyAttr.type =
    {
      val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
        core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
          core.EmptyAttr, ())
      el$proxy1.attr:core.EmptyAttr.type
    }
  val attr: core.EmptyAttr.type = $proxy2
  val $proxy3: core.Sib[Unit, ("hello world" : String)] =
    {
      val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
        core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
          core.EmptyAttr, ())
      core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
        "hello world")
    }
  val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
  "<div>hello world"
}
error when pickling tree println(
  {
    val tag: ("div" : String) = "div"
    val $proxy2: core.EmptyAttr.type =
      {
        val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
          core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
            core.EmptyAttr, ())
        el$proxy1.attr:core.EmptyAttr.type
      }
    val attr: core.EmptyAttr.type = $proxy2
    val $proxy3: core.Sib[Unit, ("hello world" : String)] =
      {
        val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
          core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
            core.EmptyAttr, ())
        core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
          "hello world")
      }
    val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
    "<div>hello world"
  }
)
error when pickling tree {
  println("Hello world!")
  println(msg)
  println(
    {
      val tag: ("div" : String) = "div"
      val $proxy2: core.EmptyAttr.type =
        {
          val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
            core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
              core.EmptyAttr, ())
          el$proxy1.attr:core.EmptyAttr.type
        }
      val attr: core.EmptyAttr.type = $proxy2
      val $proxy3: core.Sib[Unit, ("hello world" : String)] =
        {
          val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit] =
            core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
              core.EmptyAttr, ())
          core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
            "hello world")
        }
      val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
      "<div>hello world"
    }
  )
}
error when pickling tree @main def hello: Unit =
  {
    println("Hello world!")
    println(msg)
    println(
      {
        val tag: ("div" : String) = "div"
        val $proxy2: core.EmptyAttr.type =
          {
            val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit]
               =
              core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
                core.EmptyAttr, ())
            el$proxy1.attr:core.EmptyAttr.type
          }
        val attr: core.EmptyAttr.type = $proxy2
        val $proxy3: core.Sib[Unit, ("hello world" : String)] =
          {
            val el$proxy1: core.El[("div" : String), core.EmptyAttr.type, Unit]
               =
              core.El.apply[("div" : String), core.EmptyAttr.type, Unit]("div",
                core.EmptyAttr, ())
            core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
              "hello world")
          }
        val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
        "<div>hello world"
      }
    )
  }
error when pickling tree () extends Object() { this: Main$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[Main$package.type])
  @main def hello: Unit =
    {
      println("Hello world!")
      println(msg)
      println(
        {
          val tag: ("div" : String) = "div"
          val $proxy2: core.EmptyAttr.type =
            {
              val el$proxy1:
                core.El[("div" : String), core.EmptyAttr.type, Unit] =
                core.El.apply[("div" : String), core.EmptyAttr.type, Unit](
                  "div", core.EmptyAttr, ())
              el$proxy1.attr:core.EmptyAttr.type
            }
          val attr: core.EmptyAttr.type = $proxy2
          val $proxy3: core.Sib[Unit, ("hello world" : String)] =
            {
              val el$proxy1:
                core.El[("div" : String), core.EmptyAttr.type, Unit] =
                core.El.apply[("div" : String), core.EmptyAttr.type, Unit](
                  "div", core.EmptyAttr, ())
              core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
                "hello world")
            }
          val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
          "<div>hello world"
        }
      )
    }
  def msg: String = "I was compiled by Scala 3. :)"
}
error when pickling tree @SourceFile("src/main/scala/Main.scala") final module class Main$package()
   extends Object() { this: Main$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[Main$package.type])
  @main def hello: Unit =
    {
      println("Hello world!")
      println(msg)
      println(
        {
          val tag: ("div" : String) = "div"
          val $proxy2: core.EmptyAttr.type =
            {
              val el$proxy1:
                core.El[("div" : String), core.EmptyAttr.type, Unit] =
                core.El.apply[("div" : String), core.EmptyAttr.type, Unit](
                  "div", core.EmptyAttr, ())
              el$proxy1.attr:core.EmptyAttr.type
            }
          val attr: core.EmptyAttr.type = $proxy2
          val $proxy3: core.Sib[Unit, ("hello world" : String)] =
            {
              val el$proxy1:
                core.El[("div" : String), core.EmptyAttr.type, Unit] =
                core.El.apply[("div" : String), core.EmptyAttr.type, Unit](
                  "div", core.EmptyAttr, ())
              core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
                "hello world")
            }
          val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
          "<div>hello world"
        }
      )
    }
  def msg: String = "I was compiled by Scala 3. :)"
}
error when pickling tree package <empty> {
  import core.*
  final lazy module val Main$package: Main$package = new Main$package()
  @SourceFile("src/main/scala/Main.scala") final module class Main$package()
     extends Object() { this: Main$package.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Main$package.type])
    @main def hello: Unit =
      {
        println("Hello world!")
        println(msg)
        println(
          {
            val tag: ("div" : String) = "div"
            val $proxy2: core.EmptyAttr.type =
              {
                val el$proxy1:
                  core.El[("div" : String), core.EmptyAttr.type, Unit] =
                  core.El.apply[("div" : String), core.EmptyAttr.type, Unit](
                    "div", core.EmptyAttr, ())
                el$proxy1.attr:core.EmptyAttr.type
              }
            val attr: core.EmptyAttr.type = $proxy2
            val $proxy3: core.Sib[Unit, ("hello world" : String)] =
              {
                val el$proxy1:
                  core.El[("div" : String), core.EmptyAttr.type, Unit] =
                  core.El.apply[("div" : String), core.EmptyAttr.type, Unit](
                    "div", core.EmptyAttr, ())
                core.Sib.apply[Unit, ("hello world" : String)](el$proxy1.child,
                  "hello world")
              }
            val child: core.Sib[Unit, ("hello world" : String)] = $proxy3
            "<div>hello world"
          }
        )
      }
    def msg: String = "I was compiled by Scala 3. :)"
  }
}
java.lang.AssertionError: assertion failed: val el$proxy1 while running pickler on /home/kkd/blog/core/src/main/scala/Main.scala
[info] exception occurred while compiling /home/kkd/blog/core/src/main/scala/Main.scala, /home/kkd/blog/core/src/main/scala/core/Env.scala, /home/kkd/blog/core/src/main/scala/core/Tmpl.scala
java.lang.AssertionError: assertion failed: val el$proxy1 while compiling /home/kkd/blog/core/src/main/scala/Main.scala, /home/kkd/blog/core/src/main/scala/core/Env.scala, /home/kkd/blog/core/src/main/scala/core/Tmpl.scala
[error] ## Exception when compiling 3 sources to /home/kkd/blog/core/target/scala-3.3.0/classes
[error] java.lang.AssertionError: assertion failed: val el$proxy1
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:329)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:567)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$5(TreePickler.scala:491)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:491)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:323)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:341)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:567)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$5(TreePickler.scala:491)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:491)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:535)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$2(TreePickler.scala:449)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:449)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:491)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:323)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:341)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:582)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:374)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:374)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:608)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:338)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:584)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:374)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:374)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:624)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:798)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:805)
[error] dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:90)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:142)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.Pickler.run(Pickler.scala:142)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:324)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:328)
[error] dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:150)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:280)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:195)
[error] dotty.tools.dotc.Run.compile(Run.scala:179)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:505)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:171)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2369)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2319)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2317)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error] java.base/java.lang.Thread.run(Thread.java:1623)
[error]            
[error] java.lang.AssertionError: assertion failed: val el$proxy1
[error]         at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:329)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:567)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$5(TreePickler.scala:491)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:491)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:323)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:341)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:567)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$5(TreePickler.scala:491)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:491)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:535)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$2(TreePickler.scala:449)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:449)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:491)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:323)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:341)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:582)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:374)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:374)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:608)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:338)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:584)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:374)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:374)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:624)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:798)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:805)
[error]         at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:90)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:142)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:333)
[error]         at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:142)
[error]         at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:324)
[error]         at scala.collection.immutable.List.map(List.scala:246)
[error]         at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:328)
[error]         at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:150)
[error]         at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
[error]         at dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
[error]         at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
[error]         at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
[error]         at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error]         at dotty.tools.dotc.Run.compileUnits(Run.scala:280)
[error]         at dotty.tools.dotc.Run.compileSources(Run.scala:195)
[error]         at dotty.tools.dotc.Run.compile(Run.scala:179)
[error]         at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
[error]         at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error]         at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error]         at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error]         at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error]         at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
[error]         at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
[error]         at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
[error]         at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error]         at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error]         at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error]         at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error]         at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418)
[error]         at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:505)
[error]         at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405)
[error]         at sbt.internal.inc.Incremental$.apply(Incremental.scala:171)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error]         at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2369)
[error]         at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2319)
[error]         at sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[error]         at sbt.internal.io.Retry$.apply(Retry.scala:47)
[error]         at sbt.internal.io.Retry$.apply(Retry.scala:29)
[error]         at sbt.internal.io.Retry$.apply(Retry.scala:24)
[error]         at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error]         at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2317)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]         at sbt.Execute.work(Execute.scala:292)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error]         at java.base/java.lang.Thread.run(Thread.java:1623)
[error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed: val el$proxy1
[error] Total time: 3 s, completed Jul 6, 2023, 10:33:01AM

Activity

changed the title [-]Transparent inline codes causing compiler assertion error duing pickling tree phase[/-] [+]Transparent inline codes causing compiler assertion error during pickling tree phase[/+] on Jul 6, 2023
smarter

smarter commented on Jul 6, 2023

@smarter
Member

Runnng with -Ycheck:all we can see that something is already wrong at Typer:

checking try/i18151b.scala after phase typer
-- Warning: try/i18151b.scala:5:17 ---------------------------------------------
5 |  println(tmplStr(el("div") >> "hello world"))
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |symbol i18151b$package$._$el$proxy1 is defined at least twice in different parts of AST
ngsksy

ngsksy commented on Jul 7, 2023

@ngsksy
Author

The problem seems to be regarding the inline parameter in transparent inline methods, as deleting the inline modifications allows compiler to run and produce properly inlined code. Meanwhile, according to the document "inline parameters have call semantics equivalent to by-name parameters but allow for duplication of the code in the argument." Would it be possible that the duplication of code due to the inline parameter led to the warning "symbol i18151b$package$._$el$proxy1 is defined at least twice in different parts of AST"?

nicolasstucki

nicolasstucki commented on Jul 10, 2023

@nicolasstucki
Contributor

Mimimized

case class El[A](val attr: String, val child: String)

transparent inline def tmplStr(inline t: El[Any]): String =
  inline t match
    case El(attr, child) => attr + child

def test: Unit = tmplStr {
  val el = El("1", "2")
  El[Any](el.attr, null)
}
nicolasstucki

nicolasstucki commented on Apr 8, 2024

@nicolasstucki
Contributor

Minimization

//> using option -Xprint:typer

case class El[A](attr: String, child: String)

transparent inline def inlineTest(): String =
  inline {
    val el: El[Any] = El("1", "2")
    El[Any](el.attr, el.child)
  } match
    case El(attr, child) => attr + child

def test: Unit = inlineTest()
    def test: Unit =
      {
        {
          val $proxy1: String =
            {
              val el: El[Any] = El.apply[Any]("1", "2")
              el.attr:String
            }
          val attr: String = $proxy1
          val $proxy2: String =
            {
              val el: El[Any] = El.apply[Any]("1", "2")
              el.child:String
            }
          val child: String = $proxy2
          attr.+(child)
        }
        ()
      }

The issue is that el is duplicated.

added 2 commits that reference this issue on Apr 8, 2024
e13b98b
b87ff4b
added a commit that references this issue on Apr 10, 2024
d71a347
added this to the 3.5.0 milestone on May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @smarter@nicolasstucki@Kordyjan@ngsksy

    Issue actions

      Transparent inline codes causing compiler assertion error during pickling tree phase · Issue #18151 · scala/scala3