Skip to content
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

HKT passed as an annotation crashes the compiler #22357

Open
KacperFKorban opened this issue Jan 13, 2025 · 1 comment · May be fixed by #22368
Open

HKT passed as an annotation crashes the compiler #22357

KacperFKorban opened this issue Jan 13, 2025 · 1 comment · May be fixed by #22368
Assignees
Labels

Comments

@KacperFKorban
Copy link
Member

Compiler version

74aa123

Minimized code

@([A] =>> Int)
def i = 1

Output (click arrow to expand)

  exception occurred while typechecking ./wiadro/crash_my_scala.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: ./wiadro/crash_my_scala.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.15
    compiler version: version 3.6.4-RC1-bin-20250112-ae980a7-NIGHTLY-git-ae980a7
            settings: -classpath ./.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.6.4-RC1-bin-20250112-ae980a7-NIGHTLY/scala3-library_3-3.6.4-RC1-bin-20250112-ae980a7-NIGHTLY.jar:./.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.15/scala-library-2.13.15.jar -d ./wiadro/.scala-build/wiadro_93280764b7-4f0c182cbd/classes/main -sourceroot ./wiadro

Exception in thread "main" java.lang.AssertionError: assertion failed: invalid prefix HKTypeLambda(List(A), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int))
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.Types$NamedType.<init>(Types.scala:2304)
        at dotty.tools.dotc.core.Types$TermRef.<init>(Types.scala:2912)
        at dotty.tools.dotc.core.Types$CachedTermRef.<init>(Types.scala:2993)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.newType$1(Uniques.scala:44)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.linkedListLoop$1(Uniques.scala:56)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.enterIfNew(Uniques.scala:62)
        at dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:3047)
        at dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:3053)
        at dotty.tools.dotc.core.Types$NamedType$.apply(Types.scala:3036)
        at dotty.tools.dotc.core.Types$Type.select(Types.scala:1715)
        at dotty.tools.dotc.typer.TypeAssigner.selectionType(TypeAssigner.scala:166)
        at dotty.tools.dotc.typer.TypeAssigner.selectionType$(TypeAssigner.scala:16)
        at dotty.tools.dotc.typer.Typer.selectionType(Typer.scala:151)
        at dotty.tools.dotc.typer.Typer.typedSelectWithAdapt(Typer.scala:743)
        at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:1005)
        at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:1043)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3498)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3607)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3801)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1067)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1265)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:443)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:151)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3523)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3608)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3801)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1766)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1756)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1766)
        at dotty.tools.dotc.typer.Namer$Completer.$anonfun$15(Namer.scala:891)
        at dotty.tools.dotc.core.Annotations$LazyAnnotation.tree(Annotations.scala:142)
        at dotty.tools.dotc.core.Annotations$Annotation.ensureCompleted(Annotations.scala:88)
        at dotty.tools.dotc.typer.Typer.completeAnnotations$$anonfun$1(Typer.scala:2791)
        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.typer.Typer.completeAnnotations(Typer.scala:2791)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2885)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3505)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3607)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3712)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3758)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3187)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3511)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3515)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3607)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3712)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3758)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3320)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3557)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3608)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3801)
        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:510)
        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:383)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:395)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:395)
        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)
@mbovel
Copy link
Member

mbovel commented Jan 13, 2025

This is actually not linked to annotations per se. The same crash happens in:

def main =
  new ([A] =>> Int)(2)

Seems like some validation for the class constructor is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants