Crash depending on where in a file a certain term is referenced
See original GitHub issueCompiler version
3.0.0
Minification
Unfortunately this is super hard to minimise in isolation but I can provide a minification and reproduction with scalajs-react.
import japgolly.scalajs.react._
object BUG {
def problem = Main // crashes
val NameChanger =
ScalaComponent.builder[Int]
.stateless
.noBackend
.render_(???)
.build
def noProblem = Main // no crash
val Main =
ScalaComponent.builder[Unit]
.initialState(123)
.render(_ => NameChanger(123))
.build
}
The only difference between problem
which causes a crash, and noProblem
which doesn’t, is that problem
is defined before NameChanger
.
Reproduction
git clone https://github.com/japgolly/scalajs-react.git
cd scalajs-react
git checkout tmp/s3crash
sbt compile
Output (click arrow to expand)
[info] compiling 1 Scala source to scalajs-react/gh-pages/target/scala-3.0.0/classes ...
[info] exception occurred while typechecking scalajs-react/gh-pages/src/main/scala/ghpages/BUG.scala
[info] exception occurred while compiling scalajs-react/gh-pages/src/main/scala/ghpages/BUG.scala
java.lang.AssertionError: cannot merge Constraint(
uninstantiated variables: S
constrained types:
[X, P, S]
(using ev:
X => japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[P, S]
):
Conversion[X,
japgolly.scalajs.react.component.builder.ComponentBuilder.Step3[P, S,
Unit
]
]
bounds:
X :=
japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, S]
P := Unit
S >: (123 : Int)
ordering:
) with Constraint(
uninstantiated variables:
constrained types:
[X, P, S]
(using ev:
X => japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[P, S]
):
Conversion[X,
japgolly.scalajs.react.component.builder.ComponentBuilder.Step3[P, S,
Unit
]
]
bounds:
X :=
japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, Int]
P := Unit
S := Int
ordering:
), mergeEntries(japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, S], japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, Int]) failed while compiling scalajs-react/gh-pages/src/main/scala/ghpages/BUG.scala
[error] ## Exception when compiling 32 sources to scalajs-react/gh-pages/target/scala-3.0.0/classes
[error] java.lang.AssertionError: cannot merge Constraint(
[error] uninstantiated variables: S
[error] constrained types:
[error] [X, P, S]
[error] (using ev:
[error] X => japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[P, S]
[error] ):
[error] Conversion[X,
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step3[P, S,
[error] Unit
[error] ]
[error] ]
[error] bounds:
[error] X :=
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, S]
[error] P := Unit
[error] S >: (123 : Int)
[error] ordering:
[error] ) with Constraint(
[error] uninstantiated variables:
[error] constrained types:
[error] [X, P, S]
[error] (using ev:
[error] X => japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[P, S]
[error] ):
[error] Conversion[X,
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step3[P, S,
[error] Unit
[error] ]
[error] ]
[error] bounds:
[error] X :=
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, Int]
[error] P := Unit
[error] S := Int
[error] ordering:
[error] ), mergeEntries(japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, S], japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, Int]) failed
[error] dotty.tools.dotc.core.OrderingConstraint.mergeEntries$1(OrderingConstraint.scala:485)
[error] dotty.tools.dotc.core.OrderingConstraint.$amp$$anonfun$1(OrderingConstraint.scala:508)
[error] dotty.tools.dotc.core.OrderingConstraint.mergeArrays$1$$anonfun$1(OrderingConstraint.scala:460)
[error] scala.runtime.java8.JFunction1$mcVI$sp.apply(JFunction1$mcVI$sp.scala:18)
[error] scala.collection.immutable.Range.foreach(Range.scala:190)
[error] dotty.tools.dotc.core.OrderingConstraint.mergeArrays$2(OrderingConstraint.scala:460)
[error] dotty.tools.dotc.core.OrderingConstraint.merge$2$$anonfun$1(OrderingConstraint.scala:465)
[error] scala.runtime.function.JProcedure2.apply(JProcedure2.java:15)
[error] scala.runtime.function.JProcedure2.apply(JProcedure2.java:10)
[error] dotty.tools.dotc.util.SimpleIdentityMap$Map1.foreachBinding(SimpleIdentityMap.scala:61)
[error] dotty.tools.dotc.core.OrderingConstraint.merge$1(OrderingConstraint.scala:465)
[error] dotty.tools.dotc.core.OrderingConstraint.$amp(OrderingConstraint.scala:508)
[error] dotty.tools.dotc.core.OrderingConstraint.$amp(OrderingConstraint.scala:454)
[error] dotty.tools.dotc.core.TyperState.mergeConstraintWith(TyperState.scala:135)
[error] dotty.tools.dotc.core.TyperState.commit(TyperState.scala:124)
[error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2931)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:983)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1021)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:303)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:103)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2669)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:602)
[error] dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:652)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2639)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1377)
[error] dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1364)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1377)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1505)
[error] dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$2(Namer.scala:1505)
[error] dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1513)
[error] dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1538)
[error] dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1539)
[error] dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1550)
[error] dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1559)
[error] dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:699)
[error] dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:826)
[error] dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:727)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
[error] dotty.tools.dotc.core.Types$TermRef.underlying(Types.scala:2578)
[error] dotty.tools.dotc.core.Types$Type.widen(Types.scala:1201)
[error] dotty.tools.dotc.typer.Typer.simplify(Typer.scala:2744)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2733)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1377)
[error] dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1364)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1377)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1505)
[error] dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$2(Namer.scala:1505)
[error] dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1513)
[error] dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1538)
[error] dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1539)
[error] dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1550)
[error] dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1559)
[error] dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1642)
[error] dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:703)
[error] dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:826)
[error] dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:727)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
[error] dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2611)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2636)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2822)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2328)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2657)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2661)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2822)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2451)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2702)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
[error] dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
[error] dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
[error] dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
[error] dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:120)
[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.typer.FrontEnd.runOn(FrontEnd.scala:120)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
[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$5(Run.scala:215)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:223)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:230)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:166)
[error] dotty.tools.dotc.Run.compile(Run.scala:150)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[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:186)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:174)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:172)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:457)
[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:261)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:412)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:399)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2362)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2319)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2315)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] java.base/java.lang.Thread.run(Thread.java:834)
[error]
[error] stack trace is suppressed; run last gh-pages / Compile / compileIncremental for the full output
[error] (gh-pages / Compile / compileIncremental) java.lang.AssertionError: cannot merge Constraint(
[error] uninstantiated variables: S
[error] constrained types:
[error] [X, P, S]
[error] (using ev:
[error] X => japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[P, S]
[error] ):
[error] Conversion[X,
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step3[P, S,
[error] Unit
[error] ]
[error] ]
[error] bounds:
[error] X :=
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, S]
[error] P := Unit
[error] S >: (123 : Int)
[error] ordering:
[error] ) with Constraint(
[error] uninstantiated variables:
[error] constrained types:
[error] [X, P, S]
[error] (using ev:
[error] X => japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[P, S]
[error] ):
[error] Conversion[X,
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step3[P, S,
[error] Unit
[error] ]
[error] ]
[error] bounds:
[error] X :=
[error] japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, Int]
[error] P := Unit
[error] S := Int
[error] ordering:
[error] ), mergeEntries(japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, S], japgolly.scalajs.react.component.builder.ComponentBuilder.Step2[Unit, Int]) failed
Workarounds
Any of the following changes avoid the crash:
-
- val NameChanger = + val NameChanger: ScalaComponent[Int, Unit, Unit, CtorType.Props] =
-
- val Main = + val Main: ScalaComponent[Unit, Int, Unit, CtorType.Nullary] =
-
- .initialState(123) + .initialState[Int](123)
-
.initialState(123) + .noBackend // this is normally an implicit conversion
-
- .render(_ => NameChanger(123)) + .render(_ => NameChanger.ctor(123)) // this is normally an implicit conversion
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Collecting User-Mode Dumps - Win32 apps | Microsoft Learn
For service crashes, the dump is written to service specific profile folders depending on the service account used. For example, the profile ...
Read more >Crash (computing) - Wikipedia
In computing, a crash, or system crash, occurs when a computer program such as a software application or an operating system stops functioning...
Read more >Network Screening with Crash Data – Frequency
Crash rates are calculated by dividing the total number of crashes at a given roadway section or intersection over a specified time period...
Read more >Florida Statutes § 316.066 - Online Sunshine
(1)(a) A Florida Traffic Crash Report, Long Form must be completed and ... to access that information and file a written sworn statement...
Read more >Fault in "Chain Reaction" Car Accidents - Nolo
Many of these crashes involve two vehicles, but some occur when three or more ... Depending on the type of car insurance coverage...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh crap I was planning on trying again to minimise this further but it completely slipped my mind. Thanks @smarter, it wouldn’t have been fun at all.
It wasn’t fun to do, but I managed to minimize this to: