-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Regression in 3.5: Infinite recursion during typecheck of polymorphic-recursion with match types #21015
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
Labels
area:match-types
area:pattern-matching
itype:bug
regression
This worked in a previous version but doesn't anymore
Milestone
Comments
Note: this version is almost the same but doesn't have mutually recursive match types and compiles ok type Init[Coll[_], A, T <: Tuple] = T match
case EmptyTuple => A
case head *: rest =>
head match
case Int => Init[Coll, Coll[A], rest]
case _ => Unit
def fillVector[A, T <: Tuple](dims: T)(x: => A): Init[Vector, A, T] =
dims match
case _: EmptyTuple => x
case (p: (head *: rest)) =>
val (head *: rest) = p
head match
case size: Int => fillVector(rest)(Vector.fill[A](size)(x))
case _: Any => () |
Bisect points to d421f88 |
Minimization: type M1[A] = Int match
case 1 => M2[A]
type M2[A] = Int match
case 2 => M1[Option[A]]
def m1[A](x: A): M1[A] = ???
object Test:
val _: M1[Int] = m1(1) // error
val _: M1[Int] = m1[Int](1) // ok
val _: M1[Int] =
val x = m1(1)
x // ok |
EugeneFlesselle
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 5, 2024
In pos-deep-subtype/i21015.scala:30, we ask the TypeComparer if `M1[Int] <:< M1[A]` `isMatchingApply` first tries `isSubArgs` which succeeds, but then also checks if a weaker constraint is generated by `recur(tp1.superTypeNormalized, tp2.superTypeNormalized)`. The latter throws a `RecursionOverflow` which, before the changes, bypassed the former successful check, and failed the overall subtype test. Fix scala#21015
EugeneFlesselle
added a commit
that referenced
this issue
Jul 6, 2024
In pos-deep-subtype/i21015.scala:30, we ask the TypeComparer if `M1[Int] <:< M1[A]` `isMatchingApply` first tries `isSubArgs` which succeeds, but then also checks if a weaker constraint is generated by `recur(tp1.superTypeNormalized, tp2.superTypeNormalized)`. The latter throws a `RecursionOverflow` which, before the changes, bypassed the former successful check, and failed the overall subtype test. Fix #21015
WojciechMazur
pushed a commit
that referenced
this issue
Jul 10, 2024
In pos-deep-subtype/i21015.scala:30, we ask the TypeComparer if `M1[Int] <:< M1[A]` `isMatchingApply` first tries `isSubArgs` which succeeds, but then also checks if a weaker constraint is generated by `recur(tp1.superTypeNormalized, tp2.superTypeNormalized)`. The latter throws a `RecursionOverflow` which, before the changes, bypassed the former successful check, and failed the overall subtype test. Fix #21015 [Cherry-picked 2d0e373]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:match-types
area:pattern-matching
itype:bug
regression
This worked in a previous version but doesn't anymore
Compiler version
This code breaks compilation on 3.5.0-RC2 but works on 3.4.2
Minimized code
Output
Expectation
The text was updated successfully, but these errors were encountered: