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
Spurious " has non-class parent: val <none>" warnings/errors #16036
Comments
@odersky , that's the issue I mentioned during our conversation. In order to reproduce on izumi:
Watch the build log. There will be stacktraces like:
The build will succeed regardless. It might be interesting that the "problematic" classes differ from run to run. That makes me think that it might be some kind of a race condition in the compiler. I still can't isolate it but it is easily reproducible and, as you requested, the stacktraces are available. |
I'm seeing what looks to be an identical crash in one of my own projects. Stack tracejava.lang.AssertionError: assertion failed: trait AutoRollback has non-class parent: val scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8) dotty.tools.dotc.core.SymDenotations$ClassDenotation.traverse$1(SymDenotations.scala:1912) dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeBaseData(SymDenotations.scala:1917) dotty.tools.dotc.core.SymDenotations$BaseDataImpl.apply(SymDenotations.scala:2889) dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseData(SymDenotations.scala:1883) dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseClassSet(SymDenotations.scala:1899) dotty.tools.dotc.core.SymDenotations$ClassDenotation.derivesFrom(SymDenotations.scala:1925) dotty.tools.dotc.core.Types$Type.loop$1(Types.scala:268) dotty.tools.dotc.core.Types$Type.derivesFrom(Types.scala:292) dotty.tools.dotc.typer.Namer$ClassCompleter.checkedParentType$1(Namer.scala:1490) dotty.tools.dotc.typer.Namer$ClassCompleter.$anonfun$27(Namer.scala:1558) scala.collection.immutable.List.map(List.scala:246) dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:1558) dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:810) dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:173) dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187) dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189) dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:380) dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2836) dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2861) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029) dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3051) dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3101) dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1063) dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1067) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2903) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029) dotty.tools.dotc.typer.Typer.typedNew(Typer.scala:814) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2899) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958) dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:491) dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:414) dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:492) dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:884) dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:884) dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:576) dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:640) dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:479) dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:766) dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:883) dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1095) dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:346) dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:121) dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:941) dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$3(Applications.scala:1021) dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3169) dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1032) dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1070) dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:346) dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:121) dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:2779) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2934) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029) dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3078) dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3101) dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1063) dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1067) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2903) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958) dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:491) dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:414) dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:492) dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:884) dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:884) dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:576) dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:640) dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:479) dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:766) dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:883) dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1095) dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:346) dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:121) dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:941) dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$3(Applications.scala:1021) dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3169) dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1032) dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1070) dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:346) dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:121) dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:2779) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2934) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029) dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3078) dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3101) dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2532) dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2883) dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2887) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029) dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3051) dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3101) dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2659) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2928) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029) dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3145) dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44) dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54) scala.Function0.apply$mcV$sp(Function0.scala:42) dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:429) dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54) dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88) scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) scala.collection.immutable.List.foreach(List.scala:333) dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88) dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:238) scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321) dotty.tools.dotc.Run.runPhases$1(Run.scala:249) dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:257) dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:266) dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68) dotty.tools.dotc.Run.compileUnits(Run.scala:266) dotty.tools.dotc.Run.compileSources(Run.scala:190) dotty.tools.dotc.Run.compile(Run.scala:174) dotty.tools.dotc.Driver.doCompile(Driver.scala:35) dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88) dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22) sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91) sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193) scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248) sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183) sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163) sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239) sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163) sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211) sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534) sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534) sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179) sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177) sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463) sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116) sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56) sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52) sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263) sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418) sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506) sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405) sbt.internal.inc.Incremental$.apply(Incremental.scala:171) sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534) sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488) sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332) sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425) sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137) sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2363) sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2313) sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30) sbt.internal.io.Retry$.apply(Retry.scala:46) sbt.internal.io.Retry$.apply(Retry.scala:28) sbt.internal.io.Retry$.apply(Retry.scala:23) sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30) sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2311) scala.Function1.$anonfun$compose$1(Function1.scala:49) sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) sbt.std.Transform$$anon$4.work(Transform.scala:68) sbt.Execute.$anonfun$submit$2(Execute.scala:282) sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) sbt.Execute.work(Execute.scala:291) sbt.Execute.$anonfun$submit$1(Execute.scala:282) sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) sbt.CompletionService$$anon$2.call(CompletionService.scala:64) java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) java.base/java.lang.Thread.run(Thread.java:833) (postgres / Test / compileIncremental) java.lang.AssertionError: assertion failed: trait AutoRollback has non-class parent: valThis is a project using ScalikeJDBC 4.0.0 and the assertion is thrown only when compiling tests (i.e. "sbt test"). I can compile the project successfully (i.e. "sbt clean compile") every time - the assertion has something to do with my test classes it seems. The referenced "AutoRollback" trait is from ScalikeJDBC, not from my code. |
It's probably not a race condition but a an error that depends on the order of files to be compiled. And the problem seems to be (as almost always) that there is a cyclic reference that the compiler cannot resolve. |
I think it would be important to minimize it but I don't have the time. Can someone help me here? The problem of @pshirshov looks like it can easily be avoided since it happens during import suggestions and we can simply turn off the assert then. The problem of @Nexus6 is more serious and harder to fix. Essentially we end up with an illegal state in a core operation -- computing the base types of a type. I could simply turn off the assert and return no base type, but I really would like to find out what goes wrong here because this could be a deeper problem. Turning off the assert would simply mask the underlying problem which will make it much less likely to be fixed. |
A minimization should be a small number of self contained files that demonstrates the problem. Typically it goes like this:
|
Ok, I'll try. |
@pshirshov Thanks! But I actually think it would be easier to start with the problem experienced by @Nexus6. The problem you are seeing is when the compiler tries to find suggestions for imports. That process depends not just on the files you compile and their dependencies but the whole classpath. That makes it hard to reproduce by definition. As far as I can see the problem experienced by @Nexus6 is a full compiler crash for normal compilation. As a first step it would be good to find out whether it is still present in 3.3.0. |
@odersky To create a reproducible test case, I used vscode+metals to create a minimal sbt project from the Scala3 template. To this I added the ScalikeJDBC, specs2, and munit dependencies from the project where I originally observed the crash. In addition, I added a stripped-down version of one of the test classes that was originally generated for me, from an existing db schema, by ScalikeJDBC. Github is not allowing me to attach the project archive (.tar.gz - 1.2K) here but you can download it here or let me know of some other way I can get it to you if you're interested. Just download, unpack, switch to the new project directory, run "sbt test" and the crash should happen every time. I tested this on my x86_64 machine and on an ARM64 machine - same crash. Interestingly, the test class shouldn't compile at all as I left the source file for the "Header" model class out of the project. But the crash occurs before the compiler even gets to the point of complaining about the missing class. |
We spotted another strange trace in come code using izumi-reflect. We'll try to isolate it but as with the previous trace it might be tricky.
|
Actually, this time the repro is stable and laughably simple: https://scastie.scala-lang.org/lUnGyx2XSXu81ZLWKCvw8A |
I've been getting errors like Start with a file def hello(name : String) : String = s"Hi $name" Place it alone in a directory and
If you build the jar file and use the That's probably just a default package thing! If you put a package declaration in So, from a jar file it works. But if you compile, search
Ah ha! Everything works (including scaladoc from the tasty file) if you just rename the file TL; DR: Avoid source file names with The error message could be a bit clearer, though. |
@odersky [info] tree: EmptyTree |
@pshirshov's minimization is still valid: //> using dep dev.zio::izumi-reflect:2.3.8
import izumi.reflect.Tag
@main def main = println(Tag[Array[Byte]]) We still need a minimization without the |
Well, as @odersky said once, our macros are one of the toughest compiler stresstests. These things are prohibitively hard to untangle. |
The |
@Nexus6 Your link is not active anymore. Is there any chance you could repost your reproduction to somewhere more stable? |
I could reliably reproduce #16036 (comment) on 3.2.2. On the latest Note that to be able to compile all the tests on the nightly, I had to apply the following change to the test sources. The previous code was rule out as unsound. diff --git a/distage/distage-testkit-scalatest/src/main/scala-3/izumi/distage/testkit/scalatest/SpecWiring.scala b/distage/distage-testkit-scalatest/src/main/scala-3/izumi/distage/testkit/scalatest/SpecWiring.scala
index 620e618d4..4aebd4d30 100644
--- a/distage/distage-testkit-scalatest/src/main/scala-3/izumi/distage/testkit/scalatest/SpecWiring.scala
+++ b/distage/distage-testkit-scalatest/src/main/scala-3/izumi/distage/testkit/scalatest/SpecWiring.scala
@@ -3,14 +3,14 @@ package izumi.distage.testkit.scalatest
import izumi.distage.framework.{CheckableApp, PlanCheckConfig, PlanCheckMaterializer}
import izumi.distage.modules.DefaultModule
-abstract class SpecWiring[AppMain <: CheckableApp, Cfg <: PlanCheckConfig.Any](
+abstract class SpecWiring[F[_], AppMain <: CheckableApp { type AppEffectType[X] = F[X] }, Cfg <: PlanCheckConfig.Any](
val app: AppMain,
val cfg: Cfg = PlanCheckConfig.empty,
val checkAgainAtRuntime: Boolean = true,
)(implicit
val planCheck: PlanCheckMaterializer[AppMain, Cfg],
- defaultModule: DefaultModule[app.AppEffectType],
-) extends Spec1[app.AppEffectType]()(app.tagK, defaultModule)
+ defaultModule: DefaultModule[F],
+) extends Spec1[F]()(app.tagK, defaultModule)
with WiringAssertions {
s"Wiring check for `${planCheck.app.getClass.getCanonicalName}`" should { However, that is not related to the previous crash. Even with that fix, 3.2.2 still reliably logged |
Sorry about that. I pushed to a new repo, you can grab the code here: https://github.com/Nexus6/dotty16036.git . Just run "sbt test" on it. The crash is still happening on 3.4.1, when compiling the HeaderSpec.scala class. I'm seeing
|
Thanks. I minimized down to using only the following dependency: "org.scalikejdbc" %% "scalikejdbc-test" % "4.0.0" with the following Scala code: import scalikejdbc.specs2.mutable.AutoRollback
class Foo extends AutoRollback It still crashes on the |
OK looks to me like it makes sense, actually. There is no The So it doesn't seem like a bug in the compiler to me. It seems like a corrupted/mis-published library. |
Using the following dependencies fixes the issue: libraryDependencies ++= Seq(
"org.scalikejdbc" %% "scalikejdbc-test" % "4.0.0",
"org.specs2" %% "specs2-core" % "4.20.5",
) So yes, I don't think this is a compiler issue. |
Nice sleuthing. Can confirm that your test-case tweak of using specs2-core 4.20.5 makes the assertion error go away - no more compiler crash. My question is then: is a fatal AssertionError with a cryptic error message the best way to handle this condition in the released builds of the compiler? Could it, and should it, be handled in a more user-friendly way? From your description of the problem it sounds like this might be a fairly common occurrence, so maybe 1) issue an informative error message, then 2) perform an orderly compiler exit? |
This is the core issue. That library must have actively configured something to go against the current. In doing so, they are bypassing the user-friendly checks that are normally in place. There's not much we can do about that, I'm afraid. |
I'm going to optimistically close this issue, since I believe I have exhausted all the reproductions that have been mentioned in this thread. Feel free to reopen if it still happens on nightly, or on the soon-to-be-released 3.5.0-RC1. |
3.1.3
This looks some kind of a race condition in the compiler because it's not always happening on my machine.
From time to time I'm getting output like this while compiling classes which use
BIOCatsMonad
In my case this does not prevent the compiler from going further though other users report compiler crashes with messages like
At this moment I cannot produce minimal repro and even reliable repro, I wasn't able to reproduce the crashes too.
The text was updated successfully, but these errors were encountered: