Closed jiribenes closed 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.
Non-exhaustive pattern matching, missing case Some(true)
Using the else for a match also doesn't work
else
match
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:
Non-exhaustive pattern matching, missing case true
def foo(b: Bool) = b match { case false => false case b => b }
The following (IMO valid) program
returns an error
Non-exhaustive pattern matching, missing case Some(true)
which is clearly nonsense here.Using the
else
for amatch
also doesn't workMoreover, even the following program (and its
else
variant) fails with theNon-exhaustive pattern matching, missing case true
error: