Exhaustiveness checking tries to enforce cases which should not be possible #4152
Labels
patterns
Issues related to pattern matching.
request
Requests to resolve a particular developer problem
type-inference
Type inference, issues or improvements
Consider the following example:
This is a compile error (
The type 'MyEnum' is not exhaustively matched by the switch cases since it doesn't match 'MyEnum.b'
), even though after the if statementvalue
cannot beMyEnum.b
. Is there a deeper underlying reason that exhaustiveness checking can't handle cases like this?Sometimes code like this can be refactored to avoid this issue (putting everything into one switch statement/expression, for example), but the code could become a lot clunkier.
The text was updated successfully, but these errors were encountered: