effekt-lang / effekt

A language with lexical effect handlers and lightweight effect polymorphism
https://effekt-lang.org
MIT License
334 stars 24 forks source link

Overzealous exhaustiveness checker for booleans #652

Closed jiribenes closed 1 month ago

jiribenes commented 1 month ago

The following (IMO valid) program

def foo(opt: Option[Bool]) = opt match {
  case Some(false) => Some(false)
  case opt => Some(true)
}

returns an error Non-exhaustive pattern matching, missing case Some(true) which is clearly nonsense here.

Using the else for a match also doesn't work

def foo(opt: Option[Bool]) = opt match {
  case Some(false) => Some(false)
} else Some(true)

Moreover, even the following program (and its else variant) fails with the Non-exhaustive pattern matching, missing case true error:

def foo(b: Bool) = b match {
  case false => false
  case b => b
}