Skip to content

Nonsense opaque type in extension crashes typer #23036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jchyb opened this issue Apr 23, 2025 · 0 comments
Open

Nonsense opaque type in extension crashes typer #23036

jchyb opened this issue Apr 23, 2025 · 0 comments

Comments

@jchyb
Copy link
Contributor

jchyb commented Apr 23, 2025

Compiler version

3.6.4

Minimized code

extension (self: Int) {
  opaque type Maybe[+A] = A
}

Output (click arrow to expand)

-- [E040] Syntax Error: /Users/jchyb/kyo/minim/minim2.scala:2:9 ----------------
2 |  opaque type Maybe[A] = A
  |         ^^^^
  |         'def' expected, but 'type' found

  exception occurred while typechecking /Users/jchyb/kyo/minim/minim2.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/jchyb/kyo/minim/minim2.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.0
            settings: -classpath /Users/jchyb/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.0/scala3-library_3-3.5.0.jar:/Users/jchyb/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/jchyb/kyo/minim/.scala-build/minim_cef53d4a2d-8ccf584787/classes/main -sourceroot /Users/jchyb/kyo/minim

Exception in thread "main" java.lang.AssertionError: assertion failed
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
        at dotty.tools.dotc.core.Types$RefinedType.<init>(Types.scala:3295)
        at dotty.tools.dotc.core.Types$CachedRefinedType.<init>(Types.scala:3340)
        at dotty.tools.dotc.core.Types$RefinedType$.apply(Types.scala:3349)
        at dotty.tools.dotc.core.Types$ClassInfo.refineSelfType$1(Types.scala:5548)
        at dotty.tools.dotc.core.Types$ClassInfo.integrateOpaqueMembers$$anonfun$1(Types.scala:5552)
        at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183)
        at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179)
        at scala.collection.immutable.List.foldLeft(List.scala:79)
        at dotty.tools.dotc.core.Types$ClassInfo.integrateOpaqueMembers(Types.scala:5532)
        at dotty.tools.dotc.typer.Namer$ClassCompleter.completeConstructor(Namer.scala:1530)
        at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:1679)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:850)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
        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:393)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3206)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3426)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3477)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3558)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3669)
        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)
@jchyb jchyb added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 23, 2025
@Gedochao Gedochao added area:extension-methods area:opaque-types and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 24, 2025
@hamzaremmal hamzaremmal self-assigned this Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants