-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Compiler crash while porting from Scala 2 to Scala 3 #19560
Comments
I see the crash is in desugaring a lambda function, however it would really help if you can share any code if possible. If the code is able to be shared, a GitHub repo with some steps that can reproduce is enough for us to start with |
In fact the Desugar code in question clearly has a problem. Let me fix that and we'll see whether that solves it. |
This might fix scala#19560.
When/how could I test the fix? I am not in any hurry, but if there is anything to report, I would like to do it soon, in case any related problems appear. |
Please observe tomorrow for the next nightly release at https://central.sonatype.com/artifact/org.scala-lang/scala3-compiler_3 (they are published around 05:00 CET) |
@nicolasstucki I think I have found a small repro, as after the fix the code which was previously working is now reported as invalid. As the error pointed to a particular code, it was easy to extract. object Main {
def main(args: Array[String]): Unit = {
val a = Seq(0 -> 1, 2 -> 3)
val c = Seq("A", "B")
for (((beg, end), c) <- a.lazyZip(a)) yield c
}
}
The error is:
I am not sure if the error is supposed to happen or not, not understanding all 3.4 deprecations. It might be related to #18842. |
we should mark this as fixed, and open another issue for your problem |
Compiler version
3.3.1 and 3.4.0-RC1
Minimized code
I do not have any. The project is large, uses multiple libraries including macros and the error is not very helpful in finding the source of the error.
Output (click arrow to expand)
[error] java.lang.AssertionError: Cannot change span of EmptyTree
[error] dotty.tools.dotc.ast.Trees$EmptyTree.withSpan(Trees.scala:1067)
[error] dotty.tools.dotc.ast.Trees$EmptyTree.withSpan(Trees.scala:1067)
[error] dotty.tools.dotc.ast.desugar$.patternsToParams$$anonfun$1(Desugar.scala:1610)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.ast.desugar$.patternsToParams(Desugar.scala:1610)
[error] dotty.tools.dotc.typer.Typer.typedFunctionValue(Typer.scala:1630)
[error] dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:1416)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3170)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:509)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:432)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:510)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:912)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:912)
[error] dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:604)
[error] dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:668)
[error] dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:490)
[error] dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:794)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:911)
[error] dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1141)
[error] dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:350)
[error] dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:121)
[error] dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:984)
[error] dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1067)
[error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3461)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1078)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1116)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:350)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:121)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3160)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3210)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3437)
[error] dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1200)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3168)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.typedIf(Typer.scala:1289)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3169)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3374)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
[error] dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1193)
[error] dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1197)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3168)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3437)
[error] dotty.tools.dotc.typer.Typer.$anonfun$62(Typer.scala:2602)
[error] dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
[error] dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2602)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3136)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3243)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3347)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2789)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3148)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3152)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3243)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3347)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2922)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3194)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3374)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2922)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3194)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3437)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:477)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
[error] dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
[error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
[error] scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
[error] scala.collection.immutable.List.prependedAll(List.scala:155)
[error] scala.collection.immutable.List$.from(List.scala:684)
[error] scala.collection.immutable.List$.from(List.scala:681)
[error] scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
[error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:100)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
[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:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:337)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:348)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:357)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:71)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:357)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:261)
[error] dotty.tools.dotc.Run.compile(Run.scala:246)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[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:180)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464)
[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:419)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:172)
[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:2371)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321)
[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:2319)
[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:572)
[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:1583)
[error]
The text was updated successfully, but these errors were encountered: