-
Notifications
You must be signed in to change notification settings - Fork 1.1k
False positive exhaustivity warning on GADTs #13548
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
Comments
Can't tell yet where the problem is but given a scrutinee of type
What would we hope to get? Refined to something like Maybe
I'll check the |
The alternative is something like Or maybe |
the minimization we're currently looking at is: sealed trait Foo[S, A]
final case class Bar[B](foo: Foo[B, B]) extends Foo[B, B]
def pmat[U, C](scrut: Foo[U, C]): Unit =
scrut match
case Bar(_) => compared to Noel's code, we've eliminated and you need must it really be that complicated? there are so many parts here |
aha, finally found something simpler in several respects: sealed trait Foo[S, A]
final case class Bar[B]() extends Foo[B, B]
def pmat[U](scrut: Foo[U, String]): Unit =
scrut match
case Bar() => can't see any way to remove anything else (though it's hard to be 100% sure) but it seems peculiar that this doesn't reproduce the bug: sealed trait Foo[S, A]
final case class Bar[B]() extends Foo[B, B]
def pmat[U, C](scrut: Foo[U, C]): Unit =
scrut match
case Bar() => any fix should probably test all these variations, since it isn't clear what the one true minimization is — is it better to eliminate the case class parameter, or better to eliminate the use of a concrete type in the type of |
👏 Nice one! |
I have a case with exhaustivity checking complaining that an exhaustive match is not exhaustive. Amusingly, if I add a placeholder (
case _ => ...
) the compiler then complains that the placeholder is not reachable. I have checked this in Scala 3.0, 3.0.1, 3.0.2, and 3.1.0-RC2. The full code is in: https://github.com/noelwelsh/repastHere is a minimization, which demonstrates the exhaustivity checking issue but not the issue with a placeholder. Tested in Scala 3.1.0-RC2:
I can create a repo with this if useful.
The issue appears to be related to having two type parameters both having the same type. If I change
extends Exhausted[A, A]
toextends Exhausted[S, A]
the error goes away.The text was updated successfully, but these errors were encountered: