-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Compiler version
3.7.4, 3.8.0-RC3
Minimized code
The code is dependency-free, but not minimised, because I'm porting it from the Parsley library.
Requires two files for macro expansion
main.scala
//> using scala 3.8.0-RC3
//> using option -experimental
trait Parser:
val p = Vector(1, 2, 3)
@debuggable
object ParserImpl extends Parser
@main def hello =
println(42)
debuggable.scala
import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted.*
object Collector:
def registerNames(
names: Map[Vector[?], String],
info: Option[(String, List[(Int, Int)])]
): Unit =
???
end Collector
class debuggable extends MacroAnnotation:
// this is required for Scala 3.5+
def transform(using
Quotes
)(
tree: quotes.reflect.Definition,
companion: Option[quotes.reflect.Definition]
): List[quotes.reflect.Definition] = transform(tree)
def transform(using
Quotes
)(tree: quotes.reflect.Definition): List[quotes.reflect.Definition] =
import quotes.reflect.*
tree match
case cls @ ClassDef(clsName, constr, parents, selfOpt, body) =>
val fields = cls.symbol.fieldMembers.view.map(_.termRef)
val parsers = fields.filter(isParsley).toList
// the idea is we inject a call to Collector.registerNames with a constructed
// map from these identifiers to their compile-time names
val listOfParsers = Expr.ofList {
parsers.map(tr =>
Expr.ofTuple(
(Ident(tr).asExprOf[Vector[?]], Expr(tr.name))
)
)
}
val filePath = Expr(cls.pos.sourceFile.path)
val positionInfo = Expr.ofList(
for
termRef <- parsers
pos <- termRef.termSymbol.pos
yield Expr.ofTuple(Expr(pos.start), Expr(pos.end))
)
val parserInfo = '{ Some(($filePath, $positionInfo)) }
// 🔥🔥🔥🔥🔥🔥🔥🔥🔥
// this term causes the crash
val registration = '{
Collector
.registerNames($listOfParsers.toMap, $parserInfo)
}.asTerm
List(
ClassDef
.copy(tree)(clsName, constr, parents, selfOpt, body :+ registration)
)
report.error(
"only classes/objects containing parsers can be annotated for debugging"
)
List(tree)
end match
end transform
// this can see through type aliases
private def isParsley(using Quotes)(tyRepr: quotes.reflect.TypeRepr) =
tyRepr.asType match
case '[Vector[?]] => true
case _ => false
end debuggableOutput (click arrow to expand)
Details
> scli clean . && scli compile . --server=false
unhandled exception while running erasure on /Users/velvetbaldmime/.local/share/sniper/data/115/main.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/velvetbaldmime/.local/share/sniper/data/115/main.scala
during phase: erasure
mode: Mode(ImplicitsEnabled)
library version: version 3.8.0-RC3
compiler version: version 3.8.0-RC3
settings: -classpath /Users/velvetbaldmime/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.8.0-RC3/scala3-library_3-3.8.0-RC3.jar:/Users/velvetbaldmime/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/3.8.0-RC3/scala-library-3.8.0-RC3.jar -d /Users/velvetbaldmime/.local/share/sniper/data/115/.scala-build/115_196865c123/classes/main -experimental true -sourceroot /Users/velvetbaldmime/.local/share/sniper/data/115
Exception while compiling /Users/velvetbaldmime/.local/share/sniper/data/115/debuggable.scala, /Users/velvetbaldmime/.local/share/sniper/data/115/main.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: <no file>
during phase: parser
mode: Mode()
library version: version 3.8.0-RC3
compiler version: version 3.8.0-RC3
settings: -classpath /Users/velvetbaldmime/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.8.0-RC3/scala3-library_3-3.8.0-RC3.jar:/Users/velvetbaldmime/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/3.8.0-RC3/scala-library-3.8.0-RC3.jar -d /Users/velvetbaldmime/.local/share/sniper/data/115/.scala-build/115_196865c123/classes/main -experimental true -sourceroot /Users/velvetbaldmime/.local/share/sniper/data/115
Exception in thread "main" java.lang.AssertionError: assertion failed: missing outer accessor in object ParserImpl
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:10)
at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$outerParamAccessor(ExplicitOuter.scala:236)
at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.loop$1(ExplicitOuter.scala:460)
at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.path$extension(ExplicitOuter.scala:469)
at dotty.tools.dotc.transform.Erasure$Typer.typedThis(Erasure.scala:805)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3708)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3885)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:669)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3682)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3800)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.ReTyper.typedInlined(ReTyper.scala:100)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:911)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3730)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure$Typer.$anonfun$8(Erasure.scala:863)
at dotty.tools.dotc.core.Decorators$.zipWithConserve(Decorators.scala:160)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:863)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3707)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.ReTyper.typedInlined(ReTyper.scala:100)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:911)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3730)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.$anonfun$49(Typer.scala:2514)
at dotty.tools.dotc.core.Decorators$.loop$1(Decorators.scala:99)
at dotty.tools.dotc.core.Decorators$.mapconserve(Decorators.scala:115)
at dotty.tools.dotc.typer.Typer.typedSeqLiteral(Typer.scala:2514)
at dotty.tools.dotc.transform.Erasure$Typer.typedSeqLiteral(Erasure.scala:892)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3729)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure$Typer.$anonfun$8(Erasure.scala:863)
at dotty.tools.dotc.core.Decorators$.zipWithConserve(Decorators.scala:160)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:863)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3707)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.ReTyper.typedInlined(ReTyper.scala:100)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:911)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3730)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure$Typer.$anonfun$8(Erasure.scala:863)
at dotty.tools.dotc.core.Decorators$.zipWithConserve(Decorators.scala:160)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:863)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3707)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3885)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.ReTyper.typedInlined(ReTyper.scala:100)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:911)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3730)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.ReTyper.typedInlined(ReTyper.scala:100)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:911)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3730)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:669)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3682)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3800)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure$Typer.typedTypeApply(Erasure.scala:817)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3727)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:850)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3707)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure$Typer.$anonfun$8(Erasure.scala:863)
at dotty.tools.dotc.core.Decorators$.zipWithConserve(Decorators.scala:160)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:863)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3707)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.ReTyper.typedInlined(ReTyper.scala:100)
at dotty.tools.dotc.transform.Erasure$Typer.typedInlined(Erasure.scala:911)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3730)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3885)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3942)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3961)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1077)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3356)
at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1053)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3695)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3699)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3800)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3915)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3961)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1077)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3491)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3741)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3801)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3888)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3893)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:4004)
at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:139)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:386)
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:327)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:379)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:380)
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:1327)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:373)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:420)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:420)
at scala.Function0.apply$mcV$sp(Function0.scala:45)
at dotty.tools.dotc.Run.showProgress(Run.scala:482)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:420)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:432)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
at dotty.tools.dotc.Run.compileUnits(Run.scala:432)
at dotty.tools.dotc.Run.compileUnits(Run.scala:325)
at dotty.tools.dotc.Run.compileSuspendedUnits(Run.scala:446)
at dotty.tools.dotc.Driver.finish(Driver.scala:64)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
at dotty.tools.dotc.Driver.process(Driver.scala:213)
at dotty.tools.dotc.Driver.process(Driver.scala:181)
at dotty.tools.dotc.Driver.process(Driver.scala:193)
at dotty.tools.dotc.Driver.main(Driver.scala:223)
at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed
j-mie6