You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Richard Bradley (richard.bradley) said:
I don't think that example stands up to scrutiny. If g1 || g2 really is constant true, then rewrite your proposed:
x match {
case p if g1 => ...
case p if g2 => ...
}
to just:
x match {
case p if g1 => ...
case p => ...
}
This will a) allow the compiler to verify exhaustiveness and b) will help the reader to understand the code.
The following code compiles without warning, even though the pattern isn't exhaustive:
It looks like we special cases guards for redundancy checks but not for exhaustivity checks (https://github.com/lampepfl/dotty/blob/85ab20fd874994634b909f0883760413f6e2ef12/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala#L812), but we need to do both to be safe.
See also previous discussions in scala/bug#5365
The text was updated successfully, but these errors were encountered: