Skip to content

Incorrect exhaustivity warning in pattern matches with GADTs #19687

Open
@nrinaudo

Description

@nrinaudo

Compiler version

3.3.1

Minimized code

enum Eq[A, B]: 
  case Refl[A]() extends Eq[A, A]
  
enum T[A]:
  case S(witness: Eq[A, String])
  case I(witness: Eq[A, Int])

def partial(tagged: T[Int]) : Int =
  tagged match
    case T.I(Eq.Refl()) => 0

Output

match may not be exhaustive.
It would fail on pattern case: T.S(_)

Expectation

This warning is incorrect: it's impossible to produce an Eq[A, B] where A and B are distinct, so a T[Int] must be a T.I: a T.S would need an Eq[Int, String], which is impossible.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions