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

Exhaustivity checks are incorrect with tuple patterns bigger than 22 #16186

Closed
Sporarum opened this issue Oct 14, 2022 · 0 comments · Fixed by #19212
Closed

Exhaustivity checks are incorrect with tuple patterns bigger than 22 #16186

Sporarum opened this issue Oct 14, 2022 · 0 comments · Fixed by #19212

Comments

@Sporarum
Copy link
Contributor

Compiler version

3.2.0 / 3.2.1-RC2

Minimized code and Output

val x = 42
val tup23 = (x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x)

tup23 match {  
// ^ warning: match may not be exhaustive (wrong)
  case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => "Tuple Pattern"
} // "Tuple Pattern"

https://scastie.scala-lang.org/Sporarum/a3AOPPg2TmGhpjwxjxyrSA/199

The warning recommends do add a case _: ..., where ... is what I pasted into the RHS of Tup23 below:

val x = 42
val tup23 = (x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x)

type Tup23 = *:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,EmptyTuple]]]]]]]]]]]]]]]]]]]]]]]

tup23 match {
  case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => "Tuple Pattern"
  // ^ warning: Unreachable case (wrong)
  case _: Tup23                                                              => "Explicit type"
} // "Tuple Pattern"

https://scastie.scala-lang.org/Sporarum/a3AOPPg2TmGhpjwxjxyrSA/200

Expectation

The tupled pattern is both exhaustive and reachable, it should behave as the version with only 22 wildcards does:
https://scastie.scala-lang.org/Sporarum/a3AOPPg2TmGhpjwxjxyrSA/195

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.

2 participants