Skip to content

java.lang.AssertionError: assertion failed #20397

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

Closed
Bersier opened this issue May 13, 2024 · 6 comments
Closed

java.lang.AssertionError: assertion failed #20397

Bersier opened this issue May 13, 2024 · 6 comments
Labels
area:typer itype:bug itype:crash stat:fixed in next The issue was fixed in Next and only still applies to LTS.

Comments

@Bersier
Copy link
Contributor

Bersier commented May 13, 2024

Compiler version

3.4.1

Minimized code

trait Env2[+V]:
  type Shape <: TList[V]
  def extended(value: V): Env2[V]{ type Shape = Scope.Extended[V, Shape] }

object Scope:
  type Extended[V, L <: TList[V]] <: Nothing = L match
    case Empty.type => Nothing

trait TList[E]
case object Empty extends TList[Nothing]

Start of compiler crash error

java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:3186)
	at dotty.tools.dotc.core.Types$LazyRef.tryNormalize(Types.scala:3179)
	at dotty.tools.dotc.core.Types$Type.normalized(Types.scala:1522)
@Bersier Bersier added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels May 13, 2024
@Gedochao
Copy link
Contributor

full crash output on 3.4.1 (it's the same on 3.4.2-RC1)

assertion failure for Scope.Extended[V, ...] <:< TList[V], frozen = true

  exception occurred while typechecking /Users/pchabelski/IdeaProjects/scala-cli-tests/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 -Yno-enrich-error-messages.

     while compiling: /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/repro.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.1
            settings: -classpath /Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.1/scala3-library_3-3.4.1.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -d /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/.scala-build/compiler-repro_a5fa0afddc-28ebf8438e/classes/main -java-output-version 17 -sourceroot /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro

Exception in thread "main" java.lang.AssertionError: assertion failed
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:3186)
        at dotty.tools.dotc.core.Types$LazyRef.tryNormalize(Types.scala:3179)
        at dotty.tools.dotc.core.Types$Type.normalized(Types.scala:1522)
        at dotty.tools.dotc.core.Types$.dotty$tools$dotc$core$Types$AppliedType$$_$tryMatchAlias$1$$anonfun$1$$anonfun$1(Types.scala:4570)
        at scala.collection.immutable.List.map(List.scala:250)
        at dotty.tools.dotc.core.Types$AppliedType.tryMatchAlias$1$$anonfun$1(Types.scala:4570)
        at dotty.tools.dotc.core.MatchTypeTrace$.recurseWith(MatchTypeTrace.scala:81)
        at dotty.tools.dotc.core.Types$AppliedType.tryMatchAlias$1(Types.scala:4571)
        at dotty.tools.dotc.core.Types$AppliedType.tryNormalize(Types.scala:4576)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.recur$4(SymDenotations.scala:2218)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseTypeOf(SymDenotations.scala:2338)
        at dotty.tools.dotc.core.Types$Type.baseType(Types.scala:1194)
        at dotty.tools.dotc.core.TypeComparer.nonExprBaseType(TypeComparer.scala:1571)
        at dotty.tools.dotc.core.TypeComparer.tryBaseType$1(TypeComparer.scala:896)
        at dotty.tools.dotc.core.TypeComparer.compareAppliedType2$1(TypeComparer.scala:1410)
        at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:625)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:552)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:416)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1553)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:214)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:224)
        at dotty.tools.dotc.core.TypeComparer.isSub(TypeComparer.scala:226)
        at dotty.tools.dotc.core.ConstraintHandling.op$proxy3$1(ConstraintHandling.scala:471)
        at dotty.tools.dotc.core.ConstraintHandling.isSubTypeWhenFrozen(ConstraintHandling.scala:471)
        at dotty.tools.dotc.core.ConstraintHandling.isSubTypeWhenFrozen$(ConstraintHandling.scala:29)
        at dotty.tools.dotc.core.TypeComparer.isSubTypeWhenFrozen(TypeComparer.scala:30)
        at dotty.tools.dotc.core.TypeComparer$.isSubTypeWhenFrozen(TypeComparer.scala:3149)
        at dotty.tools.dotc.core.Types$Type.frozen_$less$colon$less(Types.scala:1104)
        at dotty.tools.dotc.core.Types$TypeBounds.$amp(Types.scala:5484)
        at dotty.tools.dotc.core.Types$TypeBounds.$amp(Types.scala:5494)
        at dotty.tools.dotc.core.Types$Type.recoverable_$amp(Types.scala:1225)
        at dotty.tools.dotc.core.Types$Type.goRefined$1(Types.scala:837)
        at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:774)
        at dotty.tools.dotc.core.Types$Type.goRec$1(Types.scala:818)
        at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:776)
        at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:936)
        at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:728)
        at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:718)
        at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:2516)
        at dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:2849)
        at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2864)
        at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2797)
        at dotty.tools.dotc.core.Substituters$.substThis(Substituters.scala:114)
        at dotty.tools.dotc.core.Substituters$SubstThisMap.apply(Substituters.scala:189)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver$$anonfun$1(Types.scala:6133)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:3192)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3343)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3339)
        at dotty.tools.dotc.core.Types$TypeAccumulator.op$proxy27$1(Types.scala:6548)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldArgs$3(Types.scala:6548)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6552)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3344)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3339)
        at dotty.tools.dotc.core.Types$TypeAccumulator.op$proxy28$1(Types.scala:6574)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6574)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3344)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3339)
        at dotty.tools.dotc.core.Types$TypeAccumulator.foldOver(Types.scala:6603)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3344)
        at dotty.tools.dotc.core.Types$RecType$$anon$3.apply(Types.scala:3339)
        at dotty.tools.dotc.core.Types$RecType.isReferredToBy(Types.scala:3348)
        at dotty.tools.dotc.core.Types$RecType$.closeOver(Types.scala:3405)
        at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:486)
        at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:16)
        at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:120)
        at dotty.tools.dotc.typer.Typer.typedRefinedTypeTree(Typer.scala:2214)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3139)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3392)
        at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1682)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1675)
        at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1682)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1777)
        at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1828)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:808)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:955)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:831)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:178)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:398)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3060)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3085)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2790)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3101)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3105)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2923)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3147)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
        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:477)
        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:684)
        at scala.collection.immutable.List$.from(List.scala:681)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:100)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
        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:337)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:350)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:360)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:360)
        at dotty.tools.dotc.Run.compileSources(Run.scala:261)
        at dotty.tools.dotc.Run.compile(Run.scala:246)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:196)
        at dotty.tools.dotc.Driver.process(Driver.scala:164)
        at dotty.tools.dotc.Driver.process(Driver.scala:176)
        at dotty.tools.dotc.Driver.main(Driver.scala:206)
        at dotty.tools.dotc.Main.main(Main.scala)

This seems to be fixed to a proper error on the current nightly

-- [E140] Cyclic Error: /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/repro.scala:3:40 
3 |  def extended(value: V): Env2[V]{ type Shape = Scope.Extended[V, Shape] }
  |                                        ^
  |illegal cyclic type reference: alias Scope.Extended[V, <refinement>.this.Shape] of ... (caught cyclic reference) ... refers back to the type itself
  |
  | Run with -explain-cyclic for more details.
-- Warning: /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/repro.scala:3:66 
3 |  def extended(value: V): Env2[V]{ type Shape = Scope.Extended[V, Shape] }
  |                                                                  ^^^^^
  |                             forward reference in refinement is deprecated
1 warning found
1 error found

@Gedochao Gedochao added stat:fixed in next The issue was fixed in Next and only still applies to LTS. area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 14, 2024
@odersky odersky closed this as completed Sep 14, 2024
@Bersier
Copy link
Contributor Author

Bersier commented Sep 15, 2024

This crash still happens in the LTS (Scala 3.3.5-RC1-bin-20240808-53791b0-NIGHTLY). It should thus be reopened.

@odersky
Copy link
Contributor

odersky commented Sep 15, 2024

This tracker is for the current version, not LTS. LTS backports fixes on a reasonable effort basis.

@Bersier
Copy link
Contributor Author

Bersier commented Sep 15, 2024

@odersky I see. Should I open another issue about this for the LTS? Or should all issues that only affect the LTS be closed?

While I personally don't care about the LTS, I do think that any valid unresolved issue applying to current releases should remain open, even if it never gets fixed. It shows the world that this issue is acknowledged, rather than dismissed. Closing an issue implies resolution (aka closure). Also, closing an issue that is unresolved basically "loses" it in a sea of other closed issues, most of which are actually resolved, and all of which get filtered out by GitHub by default.

@sjrd
Copy link
Member

sjrd commented Sep 15, 2024

Here, closing an issue means that it is resolved in the main branch. Not all repos apply the same policies.

@Bersier
Copy link
Contributor Author

Bersier commented Sep 15, 2024

@sjrd Alright. I'm not sure about the point of such an "LTS", but since I don't use it, I won't press the issue further.

I'll close #19752. #20263 should also be considered for closure, as it is resolved in the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug itype:crash stat:fixed in next The issue was fixed in Next and only still applies to LTS.
Projects
None yet
Development

No branches or pull requests

4 participants