Skip to content

Regression crash when using ? as type arg for parameter and then using match type on it #22076

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
szymon-rd opened this issue Dec 2, 2024 · 2 comments · Fixed by #22602
Closed
Assignees
Labels
area:typer itype:bug itype:crash regression This worked in a previous version but doesn't anymore

Comments

@szymon-rd
Copy link
Contributor

Compiler version

3.6.4-RC1-bin-20241201-6bf4483-NIGHTLY
Code does not crash in 3.4.2.

Minimized code

trait Foo[ CP <: NonEmptyTuple ]:
  type EndNode = Tuple.Last [CP]

def f( end : Foo[?] ) : end.EndNode =
  ???

trait Bar[CP <: NonEmptyTuple] extends Foo[CP]:
  val v: EndNode = f(this)

Output (click arrow to expand)

     while compiling: /home/srodziewicz/projects/scalapaths/test.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.15
    compiler version: version 3.6.4-RC1-bin-20241201-6bf4483-NIGHTLY-git-6bf4483
            settings: -bootclasspath /home/srodziewicz/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.6.4-RC1-bin-20241201-6bf4483-NIGHTLY/scala3-library_3-3.6.4-RC1-bin-20241201-6bf4483-NIGHTLY.jar:/home/srodziewicz/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.15/scala-library-2.13.15.jar -classpath /home/srodziewicz/projects/scalapaths/.scala-build/.bloop/scalapaths_347eda438f-99f40afdbb/bloop-internal-classes/main-tFhFrMnfQgWaax0XZu7PiA==:/home/srodziewicz/projects/scalapaths/.scala-build/scalapaths_347eda438f-99f40afdbb/classes/classes-empty-scalapaths_347eda438f-99f40afdbb -d /home/srodziewicz/projects/scalapaths/.scala-build/.bloop/scalapaths_347eda438f-99f40afdbb/bloop-internal-classes/main-tFhFrMnfQgWaax0XZu7PiA== -sourceroot /home/srodziewicz/projects/scalapaths

Error compiling project (Scala 3.6.4-RC1-bin-20241201-6bf4483-NIGHTLY, JVM (23))
Error: Unexpected error when compiling scalapaths_347eda438f-99f40afdbb: scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$)
        at dotty.tools.dotc.core.TypeComparer.disjointnessBoundary$1(TypeComparer.scala:3065)
        at dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:3068)
        at dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:3001)
        at dotty.tools.dotc.core.MatchReducer.matchSpeccedPatMat$1(TypeComparer.scala:3754)
        at dotty.tools.dotc.core.MatchReducer.matchCase$1(TypeComparer.scala:3562)
        at dotty.tools.dotc.core.MatchReducer.recur$2(TypeComparer.scala:3833)
        at dotty.tools.dotc.core.MatchReducer.op$proxy82$1(TypeComparer.scala:3862)
        at dotty.tools.dotc.core.MatchReducer.matchCases(TypeComparer.scala:3862)
        at dotty.tools.dotc.core.Types$MatchType.reduced$$anonfun$1(Types.scala:5154)
        at dotty.tools.dotc.core.TypeComparer.inSubComparer(TypeComparer.scala:3290)
        at dotty.tools.dotc.core.TypeComparer.reduceMatchWith(TypeComparer.scala:3301)
        at dotty.tools.dotc.core.TypeComparer$.reduceMatchWith(TypeComparer.scala:3472)
        at dotty.tools.dotc.core.Types$MatchType.reduced(Types.scala:5154)
        at dotty.tools.dotc.core.Types$Type.tryNormalize(Types.scala:1556)
        at dotty.tools.dotc.core.Types$Type.normalized(Types.scala:1550)
        at dotty.tools.dotc.core.Types$TypeProxy.superTypeNormalized(Types.scala:2158)
        at dotty.tools.dotc.core.TypeComparer.compareAppliedType1$1(TypeComparer.scala:1495)
        at dotty.tools.dotc.core.TypeComparer.fourthTry$1(TypeComparer.scala:1004)
        at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:812)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:570)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:432)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1595)
        at dotty.tools.dotc.core.TypeComparer.compareLower$1(TypeComparer.scala:1420)
        at dotty.tools.dotc.core.TypeComparer.compareAppliedType2$1(TypeComparer.scala:1448)
        at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:643)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:570)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:432)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1595)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:439)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:432)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1595)
        at dotty.tools.dotc.core.TypeComparer.compareNamed$1(TypeComparer.scala:318)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:357)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1595)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:229)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:239)
        at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:147)
        at dotty.tools.dotc.core.TypeComparer.necessarySubType(TypeComparer.scala:158)
        at dotty.tools.dotc.core.TypeComparer$.necessarySubType(TypeComparer.scala:3369)
        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.ProtoTypes$NoViewsAllowed$.necessarilyCompatible(ProtoTypes.scala:168)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult(ProtoTypes.scala:111)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult$(ProtoTypes.scala:32)
        at dotty.tools.dotc.typer.ProtoTypes$NoViewsAllowed$.constrainResult(ProtoTypes.scala:168)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult(ProtoTypes.scala:162)
        at dotty.tools.dotc.typer.ProtoTypes$Compatibility.constrainResult$(ProtoTypes.scala:32)
        at dotty.tools.dotc.typer.ProtoTypes$NoViewsAllowed$.constrainResult(ProtoTypes.scala:168)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:567)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:887)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:1011)
        at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1275)
        at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:434)
        at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:151)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:1084)
        at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1194)
        at dotty.tools.dotc.typer.Typer$.tryEither(Typer.scala:124)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1209)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1249)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:151)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3506)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3591)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3668)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3672)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3783)
        at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:2841)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3485)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3590)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3668)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3672)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3694)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3170)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3494)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3498)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3590)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3668)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3672)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3694)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3303)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3540)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3591)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3668)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3672)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3783)
        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:507)
        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)
@szymon-rd szymon-rd added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 2, 2024
@Gedochao Gedochao added area:typer stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced regression This worked in a previous version but doesn't anymore and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 3, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Dec 3, 2024

Last good stable version: 3.4.3
First bad stable version: 3.5.0
Last good release: 3.5.0-RC1-bin-20240406-521ce95-NIGHTLY
First bad release: 3.5.0-RC1-bin-20240408-1e8a653-NIGHTLY
Bisected commits 521ce95..1e8a653
Bisect points to ef7db7a
cc @EugeneFlesselle

@Gedochao Gedochao removed the stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced label Dec 3, 2024
@mbovel
Copy link
Member

mbovel commented Feb 14, 2025

This snippet compiles (again) since #21520.

For reference, I used the following command to find when this was fixed:

/localhome/bovel/scala3$ scala project/scripts/bisect.scala -- --should-fail --releases 3.5.0-RC1-bin-20240408-1e8a653-NIGHTLY...
3.7.0-RC1-bin-20250212-4518ce5-NIGHTLY compile playground.scala 

mbovel added a commit to mbovel/dotty that referenced this issue Feb 14, 2025
mbovel added a commit that referenced this issue Feb 14, 2025
Closes #22076.

---------

Co-authored-by: Sébastien Doeraene <[email protected]>
tgodzik pushed a commit to scala/scala3-lts that referenced this issue Apr 22, 2025
Closes scala#22076.

---------

Co-authored-by: Sébastien Doeraene <[email protected]>
[Cherry-picked a601e83]
tgodzik added a commit to scala/scala3-lts that referenced this issue Apr 22, 2025
Backport "Add regression test for scala#22076" to 3.3 LTS
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 regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants