Skip to content

Simple GADT giving "match may not be exhaustive" #10085

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
atennapel opened this issue Oct 26, 2020 · 0 comments · Fixed by #10094
Closed

Simple GADT giving "match may not be exhaustive" #10085

atennapel opened this issue Oct 26, 2020 · 0 comments · Fixed by #10094

Comments

@atennapel
Copy link

atennapel commented Oct 26, 2020

Minimized code

enum Bool:
  case True
  case False

import Bool._

enum SBool[B <: Bool]:
  case STrue extends SBool[True.type]
  case SFalse extends SBool[False.type]

import SBool._

def f(b: SBool[True.type]): Unit = b match
  case STrue => ()

https://scastie.scala-lang.org/sFyhkz0wRg2Uvtl9GE37dQ

Output

match may not be exhaustive.

It would fail on pattern case: SFalse

Expectation

I would expect f to be exhaustive because from the type parameter we can know that SFalse cannot occur. Is this a limitation of Dotty or a bug?

@liufengyun liufengyun self-assigned this Oct 26, 2020
liufengyun added a commit to dotty-staging/dotty that referenced this issue Oct 27, 2020
smarter pushed a commit to dotty-staging/dotty that referenced this issue Oct 30, 2020
liufengyun added a commit that referenced this issue Oct 30, 2020
Fix #10085: check if enum case confirms to scrutinee type
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants