scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

Typer crashes with `java.lang.AssertionError: assertion failed: TS[2, 1, 0] attempted to take ownership of A which is already owned by committable TS[3255, 2, 1, 0]` #21555

Open ChenCMD opened 2 months ago

ChenCMD commented 2 months ago

Compiler version

3.6.0-RC1-bin-20240903-21a3d39-NIGHTLY

Minimized code

trait X[F[_]]

extension [F[_]](fa: F[Any]) {
  def ex1(fa2: F[Any]): Any = ???
}

extension (a: Any) {
  def ex2[F[_]](a2: Any): F[Any] = ???
}

def g[F[_]: X]: Any = ???
def unit[A]: Any = ???
def test[F[_]: X, G[_]: X](f1: F[Any]): Any = f1.ex1(g.ex2(unit))

Output (click arrow to expand)

```scala java.lang.AssertionError: assertion failed: TS[2, 1, 0] attempted to take ownership of A which is already owned by committable TS[3255, 2, 1, 0] at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8) at dotty.tools.dotc.core.TyperState.includeVar(TyperState.scala:272) at dotty.tools.dotc.core.TyperState.$anonfun$2$$anonfun$1(TyperState.scala:234) 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.core.TyperState.$anonfun$2(TyperState.scala:233) at scala.collection.immutable.List.forall(List.scala:387) at dotty.tools.dotc.core.TyperState.mergeConstraintWith(TyperState.scala:228) at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArgs(ProtoTypes.scala:519) at dotty.tools.dotc.typer.ProtoTypes$FunProto.fold(ProtoTypes.scala:605) at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6726) at dotty.tools.dotc.core.Types$TypeTraverser.traverseChildren(Types.scala:6764) at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.traverse(Implicits.scala:680) at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763) at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763) at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.fold(ProtoTypes.scala:281) at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6726) at dotty.tools.dotc.core.Types$TypeTraverser.traverseChildren(Types.scala:6764) at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.traverse(Implicits.scala:680) at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763) at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763) at dotty.tools.dotc.typer.ProtoTypes$ViewProto.fold(ProtoTypes.scala:662) at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6726) at dotty.tools.dotc.core.Types$TypeTraverser.traverseChildren(Types.scala:6764) at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.traverse(Implicits.scala:680) at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.apply(Implicits.scala:686) at dotty.tools.dotc.typer.ImplicitRunInfo.recur$1(Implicits.scala:762) at dotty.tools.dotc.typer.ImplicitRunInfo.computeIScope(Implicits.scala:773) at dotty.tools.dotc.typer.ImplicitRunInfo.$anonfun$1(Implicits.scala:849) at dotty.tools.dotc.util.ReadOnlyMap.getOrElse(ReadOnlyMap.scala:23) at dotty.tools.dotc.typer.ImplicitRunInfo.implicitScope(Implicits.scala:849) at dotty.tools.dotc.typer.ImplicitRunInfo.implicitScope$(Implicits.scala:624) at dotty.tools.dotc.Run.implicitScope(Run.scala:43) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.implicitScope(Implicits.scala:1805) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1690) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit$$anonfun$2(Implicits.scala:1774) at dotty.tools.dotc.typer.Implicits$SearchResult.recoverWith(Implicits.scala:430) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1760) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1801) at dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1109) at dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:860) at dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:145) at dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:900) at dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:860) at dotty.tools.dotc.typer.Typer.inferView(Typer.scala:145) at dotty.tools.dotc.typer.Implicits.viewExists(Implicits.scala:873) at dotty.tools.dotc.typer.Implicits.viewExists$(Implicits.scala:860) at dotty.tools.dotc.typer.Typer.viewExists(Typer.scala:145) at dotty.tools.dotc.typer.ProtoTypes$Compatibility.necessarilyCompatible(ProtoTypes.scala:53) at dotty.tools.dotc.typer.ProtoTypes$Compatibility.necessarilyCompatible$(ProtoTypes.scala:32) at dotty.tools.dotc.typer.Typer.necessarilyCompatible(Typer.scala:145) at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult(ProtoTypes.scala:104) at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult$(ProtoTypes.scala:32) at dotty.tools.dotc.typer.Typer.constrainResult(Typer.scala:145) at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult(ProtoTypes.scala:155) at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult$(ProtoTypes.scala:32) at dotty.tools.dotc.typer.Typer.constrainResult(Typer.scala:145) at dotty.tools.dotc.typer.Typer.implicitArgs$1(Typer.scala:4142) at dotty.tools.dotc.typer.Typer.inferArgsAfter$1(Typer.scala:4136) at dotty.tools.dotc.typer.Typer.implicitArgs$1(Typer.scala:4171) at dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:4210) at dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:4266) at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4473) at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4727) at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3999) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:989) at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:1031) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3434) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1047) at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1240) at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145) at dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:3354) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3500) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3510) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:989) at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:1031) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3434) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:989) at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:1031) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3434) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1047) at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1240) at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3459) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.caseRest$1(Typer.scala:2209) at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:2225) at dotty.tools.dotc.typer.Typer.typedCases$$anonfun$1(Typer.scala:2153) at dotty.tools.dotc.core.Decorators$.loop$1(Decorators.scala:99) at dotty.tools.dotc.core.Decorators$.mapconserve(Decorators.scala:115) at dotty.tools.dotc.typer.Typer.typedCases(Typer.scala:2152) at dotty.tools.dotc.typer.Typer.$anonfun$39(Typer.scala:2143) at dotty.tools.dotc.typer.Applications.harmonic(Applications.scala:2573) at dotty.tools.dotc.typer.Applications.harmonic$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.harmonic(Typer.scala:145) at dotty.tools.dotc.typer.Typer.typedMatchFinish(Typer.scala:2143) at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:2072) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3474) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.$anonfun$65(Typer.scala:2878) at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256) at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2878) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3441) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3647) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3693) at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1427) at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1431) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3467) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedFunctionValue(Typer.scala:1915) at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:1650) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3469) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:534) at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:457) at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:535) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:1003) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:1003) at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:688) at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:752) at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:574) at dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:878) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:1002) at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1266) at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:145) at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:1075) at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1185) at dotty.tools.dotc.typer.Typer$.tryEither(Typer.scala:118) at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1200) at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1240) at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3459) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.$anonfun$65(Typer.scala:2878) at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256) at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2878) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3441) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3647) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3693) at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1427) at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1431) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3467) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedFunctionValue(Typer.scala:1915) at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:1650) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3469) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:534) at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:457) at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:535) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:1003) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:1003) at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:688) at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:752) at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:574) at dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:878) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:1002) at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1266) at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:145) at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:1075) at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1185) at dotty.tools.dotc.typer.Typer$.tryEither(Typer.scala:118) at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1200) at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1240) at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434) at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3459) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3510) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.Typer.$anonfun$65(Typer.scala:2878) at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256) at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2878) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3441) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3647) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3693) at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3141) at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3447) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3451) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3647) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3693) at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3274) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3493) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736) at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47) 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.monitor(Phases.scala:503) at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53) at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99) at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479) at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583) at scala.collection.immutable.List.prependedAll(List.scala:152) at scala.collection.immutable.List$.from(List.scala:685) at scala.collection.immutable.List$.from(List.scala:682) at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900) at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98) at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343) 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:1323) at dotty.tools.dotc.Run.runPhases$1(Run.scala:336) at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384) at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396) at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69) at dotty.tools.dotc.Run.compileUnits(Run.scala:396) at dotty.tools.dotc.Run.compileSources(Run.scala:282) at dotty.tools.dotc.Run.compile(Run.scala:267) 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.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:194) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:249) at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:184) at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:164) at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239) at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:164) at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:212) at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534) at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534) at sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:178) at sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:176) at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:454) at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:117) at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56) at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52) at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:265) at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:409) at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:496) at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:396) at sbt.internal.inc.Incremental$.apply(Incremental.scala:170) at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534) at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488) at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332) at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425) at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137) at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2427) at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2377) at sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41) at sbt.internal.io.Retry$.apply(Retry.scala:47) at sbt.internal.io.Retry$.apply(Retry.scala:29) at sbt.internal.io.Retry$.apply(Retry.scala:24) at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41) at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2375) at scala.Function1.$anonfun$compose$1(Function1.scala:49) at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63) at sbt.std.Transform$$anon$4.work(Transform.scala:69) at sbt.Execute.$anonfun$submit$2(Execute.scala:283) at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24) at sbt.Execute.work(Execute.scala:292) at sbt.Execute.$anonfun$submit$1(Execute.scala:283) at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) at sbt.CompletionService$$anon$2.call(CompletionService.scala:65) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) ```

Maybe related issues

https://github.com/scala/scala3/issues/16326 https://github.com/scala/scala3/issues/20768

Gedochao commented 2 months ago

It's not just the presentation compiler, but typer in general is crashing. Full output:

exception occurred while typechecking /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro/repro.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.

     while compiling: /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro/repro.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.6.0-RC1-bin-20240907-614170f-NIGHTLY-git-614170f
            settings: -classpath /Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.6.0-RC1-bin-20240907-614170f-NIGHTLY/scala3-library_3-3.6.0-RC1-bin-20240907-614170f-NIGHTLY.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar -d /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro/.scala-build/compiler-repro_e1e076a8a4-d9eb8ef26f/classes/main -sourceroot /Users/pchabelski/IdeaProjects/scala-cli-tests-2/untitled/compiler-repro

Exception in thread "main" java.lang.AssertionError: assertion failed: TS[1, 0] attempted to take ownership of F which is already owned by committable TS[9, 1, 0]
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.TyperState.includeVar(TyperState.scala:272)
        at dotty.tools.dotc.core.TyperState.$anonfun$2$$anonfun$1(TyperState.scala:234)
        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.core.TyperState.$anonfun$2(TyperState.scala:233)
        at scala.collection.immutable.List.forall(List.scala:387)
        at dotty.tools.dotc.core.TyperState.mergeConstraintWith(TyperState.scala:228)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArgs(ProtoTypes.scala:519)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.fold(ProtoTypes.scala:605)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6726)
        at dotty.tools.dotc.core.Types$TypeTraverser.traverseChildren(Types.scala:6764)
        at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.traverse(Implicits.scala:680)
        at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763)
        at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763)
        at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.fold(ProtoTypes.scala:281)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6726)
        at dotty.tools.dotc.core.Types$TypeTraverser.traverseChildren(Types.scala:6764)
        at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.traverse(Implicits.scala:680)
        at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763)
        at dotty.tools.dotc.core.Types$TypeTraverser.apply(Types.scala:6763)
        at dotty.tools.dotc.typer.ProtoTypes$ViewProto.fold(ProtoTypes.scala:662)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6726)
        at dotty.tools.dotc.core.Types$TypeTraverser.traverseChildren(Types.scala:6764)
        at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.traverse(Implicits.scala:680)
        at dotty.tools.dotc.typer.ImplicitRunInfo$collectParts$2$.apply(Implicits.scala:686)
        at dotty.tools.dotc.typer.ImplicitRunInfo.recur$1(Implicits.scala:762)
        at dotty.tools.dotc.typer.ImplicitRunInfo.computeIScope(Implicits.scala:773)
        at dotty.tools.dotc.typer.ImplicitRunInfo.$anonfun$1(Implicits.scala:849)
        at dotty.tools.dotc.util.ReadOnlyMap.getOrElse(ReadOnlyMap.scala:23)
        at dotty.tools.dotc.typer.ImplicitRunInfo.implicitScope(Implicits.scala:849)
        at dotty.tools.dotc.typer.ImplicitRunInfo.implicitScope$(Implicits.scala:624)
        at dotty.tools.dotc.Run.implicitScope(Run.scala:43)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.implicitScope(Implicits.scala:1805)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1690)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit$$anonfun$2(Implicits.scala:1774)
        at dotty.tools.dotc.typer.Implicits$SearchResult.recoverWith(Implicits.scala:430)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1760)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1801)
        at dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1109)
        at dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:860)
        at dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:145)
        at dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:900)
        at dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:860)
        at dotty.tools.dotc.typer.Typer.inferView(Typer.scala:145)
        at dotty.tools.dotc.typer.Implicits.viewExists(Implicits.scala:873)
        at dotty.tools.dotc.typer.Implicits.viewExists$(Implicits.scala:860)
        at dotty.tools.dotc.typer.Typer.viewExists(Typer.scala:145)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.necessarilyCompatible(ProtoTypes.scala:53)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.necessarilyCompatible$(ProtoTypes.scala:32)
        at dotty.tools.dotc.typer.Typer.necessarilyCompatible(Typer.scala:145)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult(ProtoTypes.scala:104)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult$(ProtoTypes.scala:32)
        at dotty.tools.dotc.typer.Typer.constrainResult(Typer.scala:145)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult(ProtoTypes.scala:155)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult$(ProtoTypes.scala:32)
        at dotty.tools.dotc.typer.Typer.constrainResult(Typer.scala:145)
        at dotty.tools.dotc.typer.Typer.implicitArgs$1(Typer.scala:4142)
        at dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:4210)
        at dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:4266)
        at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4473)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4727)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3999)
        at dotty.tools.dotc.typer.Typer.readapt$1(Typer.scala:4009)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4715)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3999)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736)
        at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:989)
        at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:1031)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3434)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1047)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1240)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3459)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:534)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:457)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:535)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:1003)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:1003)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:688)
        at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:752)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:574)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:878)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:1002)
        at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1266)
        at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:434)
        at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:145)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:1075)
        at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1185)
        at dotty.tools.dotc.typer.Typer$.tryEither(Typer.scala:118)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1200)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1240)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3459)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736)
        at dotty.tools.dotc.typer.Typer.$anonfun$65(Typer.scala:2878)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2878)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3441)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3647)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3693)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3141)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3447)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3451)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3543)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3647)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3693)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3493)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3544)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3621)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3625)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3736)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        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.monitor(Phases.scala:503)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:685)
        at scala.collection.immutable.List$.from(List.scala:682)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
        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:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
        at dotty.tools.dotc.Run.compileSources(Run.scala:282)
        at dotty.tools.dotc.Run.compile(Run.scala:267)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)

Happens on 3.6.0-RC1-bin-20240907-614170f-NIGHTLY-git-614170f & 3.3.3 as well.

smarter commented 2 months ago

likely a dupe of https://github.com/scala/scala3/issues/20768 / https://github.com/scala/scala3/issues/18687 / https://github.com/scala/scala3/issues/16326 which I had started working on a while ago but didn't get to the bottom of, my bad!