Skip to content

crash for -Wsafe-init with munit and munit-scalacheck #22442

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

Open
rmgk opened this issue Jan 23, 2025 · 8 comments
Open

crash for -Wsafe-init with munit and munit-scalacheck #22442

rmgk opened this issue Jan 23, 2025 · 8 comments
Labels
area:initialization area:MiMa Issues tied to binary compatibility based on semantic versioning. itype:bug itype:crash stat:needs minimization Needs a self contained minimization

Comments

@rmgk
Copy link

rmgk commented Jan 23, 2025

my best guess is this is related to munit-scalacheck being compiled with an older scala version, as copy&pasting the ScalaCheckSuite does not exhibit the error.

Still would be nice if something systematic could be done to prevent this kind of crash with safe-init

Compiler version

tested: 3.6.2, 3.6.3, 3.5.2, 3.7.0-RC1-bin-20250122-b709262-NIGHTLY

Minimized code

https://scastie.scala-lang.org/BLCh6nVwRyumizn6wi27LA

//> using scala 3.6.3
//> using option -Wsafe-init

//> using dep org.scalameta::munit::1.1.0
//> using dep org.scalameta::munit-scalacheck::1.0.0

class A extends munit.ScalaCheckSuite {}

Output (click arrow to expand)

Error: scala.MatchError: dotty.tools.dotc.core.Types$PreviousErrorType@7911d345 (of class dotty.tools.dotc.core.Types$PreviousErrorType) at dotty.tools.dotc.transform.init.Util$Call$.unapply(Util.scala:45) at dotty.tools.dotc.transform.init.Util$NewExpr$.unapply(Util.scala:65) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1224) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$38(Semantic.scala:1160) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1159) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$8(Semantic.scala:635) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$Reporter$.errorsIn(Semantic.scala:425) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$7(Semantic.scala:635) at scala.collection.immutable.List.flatMap(List.scala:294) at dotty.tools.dotc.transform.init.Semantic$.checkArgsWithParametricity$1(Semantic.scala:634) at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:673) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1189) at scala.collection.immutable.List.map(List.scala:251) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1189) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1344) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$10(Semantic.scala:718) at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:717) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1189) at scala.collection.immutable.List.map(List.scala:247) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1189) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1344) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$38(Semantic.scala:1160) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1159) at dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1$$anonfun$1(Semantic.scala:617) 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.init.Semantic$.promoteArgs$1(Semantic.scala:617) at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:682) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$38(Semantic.scala:1160) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1159) at dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1$$anonfun$1(Semantic.scala:617) 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.init.Semantic$.promoteArgs$1(Semantic.scala:617) at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:682) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433) at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$5(Semantic.scala:475) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$.dotty$tools$dotc$transform$init$Semantic$Reporter$$$_$_$$anonfun$3(Semantic.scala:440) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433) at dotty.tools.dotc.transform.init.Semantic$Reporter$.hasErrors(Semantic.scala:440) at dotty.tools.dotc.transform.init.Semantic$.widenArg(Semantic.scala:475) at dotty.tools.dotc.transform.init.Semantic$.widenArgs$$anonfun$1(Semantic.scala:489) at scala.collection.immutable.List.map(List.scala:251) at scala.collection.immutable.List.map(List.scala:79) at dotty.tools.dotc.transform.init.Semantic$.widenArgs(Semantic.scala:489) at dotty.tools.dotc.transform.init.Semantic$.instantiate(Semantic.scala:864) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$40(Semantic.scala:1231) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1229) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$4(Semantic.scala:1597) at scala.collection.immutable.List.foreach(List.scala:334) at dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1595) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1393) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$17(Semantic.scala:796) at dotty.tools.dotc.transform.init.Semantic$.callConstructor(Semantic.scala:796) at dotty.tools.dotc.transform.init.Semantic$.superCall$1$$anonfun$1(Semantic.scala:1524) at dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$3(Semantic.scala:1589) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619) at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617) at scala.collection.AbstractIterable.foreach(Iterable.scala:935) at dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1589) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1393) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.$anonfun$17(Semantic.scala:796) at dotty.tools.dotc.transform.init.Semantic$.callConstructor(Semantic.scala:796) at dotty.tools.dotc.transform.init.Semantic$.superCall$1$$anonfun$1(Semantic.scala:1524) at dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$3(Semantic.scala:1589) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619) at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617) at scala.collection.AbstractIterable.foreach(Iterable.scala:935) at dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1589) at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1393) at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112) at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184) at dotty.tools.dotc.transform.init.Semantic$.iterate$1(Semantic.scala:1133) at dotty.tools.dotc.transform.init.Semantic$.checkClass(Semantic.scala:1144) at dotty.tools.dotc.transform.init.Semantic$.checkClasses$$anonfun$2(Semantic.scala:1153) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619) at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617) at scala.collection.AbstractIterable.foreach(Iterable.scala:935) at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:905) at dotty.tools.dotc.transform.init.Semantic$.checkClasses(Semantic.scala:1152) at dotty.tools.dotc.transform.init.Checker.runOn$$anonfun$1(Checker.scala:54) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at dotty.tools.dotc.core.Phases$Phase.cancellable(Phases.scala:528) at dotty.tools.dotc.transform.init.Checker.runOn(Checker.scala:59) at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:345) 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:1324) at dotty.tools.dotc.Run.runPhases$1(Run.scala:338) at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:385) at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:397) at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69) at dotty.tools.dotc.Run.compileUnits(Run.scala:397) at dotty.tools.dotc.Run.compileSources(Run.scala:284) at dotty.tools.dotc.Run.compile(Run.scala:269) at dotty.tools.dotc.Driver.doCompile(Driver.scala:37) at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141) at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22) at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91) at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:148) at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$9(BloopHighLevelCompiler.scala:181) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:73) at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53) at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:72) at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$8(BloopHighLevelCompiler.scala:181) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81) at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101) at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74) at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717) at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)

Error: Unexpected error when compiling Slips_d8c005c033-test: scala.MatchError: dotty.tools.dotc.core.Types$PreviousErrorType@7911d345 (of class dotty.tools.dotc.core.Types$PreviousErrorType)
at dotty.tools.dotc.transform.init.Util$Call$.unapply(Util.scala:45)
at dotty.tools.dotc.transform.init.Util$NewExpr$.unapply(Util.scala:65)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1224)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$38(Semantic.scala:1160)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1159)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$8(Semantic.scala:635)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.errorsIn(Semantic.scala:425)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$7(Semantic.scala:635)
at scala.collection.immutable.List.flatMap(List.scala:294)
at dotty.tools.dotc.transform.init.Semantic$.checkArgsWithParametricity$1(Semantic.scala:634)
at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:673)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1189)
at scala.collection.immutable.List.map(List.scala:251)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1189)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1344)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$10(Semantic.scala:718)
at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:717)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1189)
at scala.collection.immutable.List.map(List.scala:247)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1189)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1344)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$38(Semantic.scala:1160)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1159)
at dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1$$anonfun$1(Semantic.scala:617)
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.init.Semantic$.promoteArgs$1(Semantic.scala:617)
at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:682)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$38(Semantic.scala:1160)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1159)
at dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1$$anonfun$1(Semantic.scala:617)
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.init.Semantic$.promoteArgs$1(Semantic.scala:617)
at dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:682)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$44(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1262)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$30(Semantic.scala:1005)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433)
at dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1002)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$5(Semantic.scala:475)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$.dotty$tools$dotc$transform$init$Semantic$Reporter$$$$$$anonfun$3(Semantic.scala:440)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:433)
at dotty.tools.dotc.transform.init.Semantic$Reporter$.hasErrors(Semantic.scala:440)
at dotty.tools.dotc.transform.init.Semantic$.widenArg(Semantic.scala:475)
at dotty.tools.dotc.transform.init.Semantic$.widenArgs$$anonfun$1(Semantic.scala:489)
at scala.collection.immutable.List.map(List.scala:251)
at scala.collection.immutable.List.map(List.scala:79)
at dotty.tools.dotc.transform.init.Semantic$.widenArgs(Semantic.scala:489)
at dotty.tools.dotc.transform.init.Semantic$.instantiate(Semantic.scala:864)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$40(Semantic.scala:1231)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1229)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$4(Semantic.scala:1597)
at scala.collection.immutable.List.foreach(List.scala:334)
at dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1595)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1393)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$17(Semantic.scala:796)
at dotty.tools.dotc.transform.init.Semantic$.callConstructor(Semantic.scala:796)
at dotty.tools.dotc.transform.init.Semantic$.superCall$1$$anonfun$1(Semantic.scala:1524)
at dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$3(Semantic.scala:1589)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617)
at scala.collection.AbstractIterable.foreach(Iterable.scala:935)
at dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1589)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1393)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:126)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.$anonfun$17(Semantic.scala:796)
at dotty.tools.dotc.transform.init.Semantic$.callConstructor(Semantic.scala:796)
at dotty.tools.dotc.transform.init.Semantic$.superCall$1$$anonfun$1(Semantic.scala:1524)
at dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$3(Semantic.scala:1589)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617)
at scala.collection.AbstractIterable.foreach(Iterable.scala:935)
at dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1589)
at dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1393)
at dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Cache.cachedEval(Cache.scala:112)
at dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1184)
at dotty.tools.dotc.transform.init.Semantic$.iterate$1(Semantic.scala:1133)
at dotty.tools.dotc.transform.init.Semantic$.checkClass(Semantic.scala:1144)
at dotty.tools.dotc.transform.init.Semantic$.checkClasses$$anonfun$2(Semantic.scala:1153)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617)
at scala.collection.AbstractIterable.foreach(Iterable.scala:935)
at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:905)
at dotty.tools.dotc.transform.init.Semantic$.checkClasses(Semantic.scala:1152)
at dotty.tools.dotc.transform.init.Checker.runOn$$anonfun$1(Checker.scala:54)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.core.Phases$Phase.cancellable(Phases.scala:528)
at dotty.tools.dotc.transform.init.Checker.runOn(Checker.scala:59)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:345)
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:1324)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:338)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:385)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:397)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
at dotty.tools.dotc.Run.compileUnits(Run.scala:397)
at dotty.tools.dotc.Run.compileSources(Run.scala:284)
at dotty.tools.dotc.Run.compile(Run.scala:269)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:148)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$9(BloopHighLevelCompiler.scala:181)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:73)
at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:72)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$8(BloopHighLevelCompiler.scala:181)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81)
at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717)
at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)

@rmgk rmgk added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 23, 2025
@Gedochao Gedochao added stat:needs minimization Needs a self contained minimization area:initialization and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 24, 2025
@rmgk
Copy link
Author

rmgk commented Jan 24, 2025

As a note, the new munit-scalacheck release does indeed make the specific issue go away.

However, I still think the (in my experience) high rate of compiler crashes for -Wsafe-init makes this feature hard to recommend, even though I quite like the added safety net :/

@liufengyun
Copy link
Contributor

liufengyun commented Jan 27, 2025

I did some initial investigation. The stacktrace contains scala.MatchError: dotty.tools.dotc.core.Types$PreviousErrorType, which means the initialization checker gets an incorrect AST.

By printing more information from the checker, we can see the error happens with pickleQuotes:

java.lang.Exception: 

fun tpe = <error wrong number of arguments at pickleQuotes for (message: String, clues: munit.Clues, loc: munit.Location): Nothing: (ScalaCheckSuite.this.fail :
  (message: String, clues: munit.Clues, loc: munit.Location): Nothing), expected: 3, found: 2>, 

tree = ScalaCheckSuite.this.fail("\n".+(renderResult(result)),
  ScalaCheckSuite.this.fail$default$2)(test.location)

/cc: @olhotak

@liufengyun
Copy link
Contributor

The difference between the two versions of munit-scalacheck is the following (highlighted line is where the problem happens):

https://github.com/scalameta/munit-scalacheck/compare/v1.0.0..v1.1.0#diff-ac658863a29561df1723a05de4a4d39c5e206a77120aa9d3e4f65aaa4d2752e2L104-L105

The method fail is from munit (there are 4 overloaded versions):

https://github.com/scalameta/munit/blob/v1.1.0/munit/shared/src/main/scala/munit/Assertions.scala#L269-L275

The problem is that the code below should not even type check:

Try(fail("\n" + renderResult(result))(test.location))

Because there is no version of fail that conforms to this shape in version v1.1.0 of munit. However, the typer failed to issue an error and stop compilation.

With munit-scalacheck v1.1.0, the following code can type check:

        implicit val loc = test.location
        Try(fail("\n" + renderResult(result)))

And after type checking, we get the following tree, which the initialization checker can handle without problem:

ScalaCheckSuite.this.fail("\n".+(renderResult(result)),
  ScalaCheckSuite.this.fail$default$2)(loc, munit.diff.DiffOptions.default)

I'd suggest minimizing this as a bug for the typer.

@olhotak
Copy link
Contributor

olhotak commented Jan 28, 2025

This looks like a binary compatibility issue.

  • munit 1.0.0 with munit-scalacheck 1.0.0 works
  • munit 1.1.0 with munit-scalacheck 1.1.0 also works
  • munit 1.1.0 with mismatched munit-scalacheck 1.0.0 breaks

@olhotak olhotak added the area:MiMa Issues tied to binary compatibility based on semantic versioning. label Jan 28, 2025
@liufengyun
Copy link
Contributor

This looks like a binary compatibility issue.

Good point, so the versions are binary compatible but not tasty compatible:

https://github.com/scalameta/munit/compare/v1.0.0..v1.1.0#diff-9709813558958e80c7175a459ff9e2ea68174e7be242b035d84f487ef075a483R268-R287

The code Try(fail("\n" + renderResult(result))(test.location)) in munit-scalacheck v1.0.0 can correctly be type checked with munit v1.0.0.

However, in the particular run they mix munit-scalacheck v1.0.0 wiht munit v1.1.0, which are binary compatible, but not tasty compatible.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 29, 2025

I guess we should add https://github.com/scalacenter/tasty-mima for the future. We can't really do too much now as it's published. Sorry about the issue and thanks @liufengyun for figuring it out!

@olhotak
Copy link
Contributor

olhotak commented Jan 29, 2025

A question remains whether pickleQuotes should emit an error message when it generates the PreviousErrorType or whether later phases should be able to tolerate a PreviousErrorType and report an error only when they need to inspect a tree with such a type.

More generally, what should be the behaviour of the compiler when it is provided two libraries that are Tasty-incompatible?

lenguyenthanh added a commit to grokking-vietnam/grox that referenced this issue Jan 29, 2025
lenguyenthanh added a commit to grokking-vietnam/grox that referenced this issue Jan 29, 2025
lenguyenthanh added a commit to grokking-vietnam/grox that referenced this issue Jan 29, 2025
@olhotak
Copy link
Contributor

olhotak commented Jan 31, 2025

The compiler does emit an error message before crashing. The crash comes only after the following error message output:

Error: wrong number of arguments at pickleQuotes for (message: String, clues: munit.Clues, loc: munit.Location): Nothing: (ScalaCheckSuite.this.fail :
  (message: String, clues: munit.Clues, loc: munit.Location): Nothing), expected: 3, found: 2

A possible fix for the crash would be for the initialization checker to ignore (with a warning) any trees whose construction from Tasty emitted errors.

olhotak added a commit that referenced this issue Mar 5, 2025
This PR would fix the error raised in
#22442.
The error arises when reading incompatible TASTy trees. This PR checks
if an error occurs when fetching the rhs of ValOrDefDef trees and gives
a warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:initialization area:MiMa Issues tied to binary compatibility based on semantic versioning. itype:bug itype:crash stat:needs minimization Needs a self contained minimization
Projects
None yet
Development

No branches or pull requests

5 participants