[SR-14189] Warn when list of patterns in case
statement is structurally similar to pattern being matched
#56567
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Additional Detail from JIRA
md5: 6f36f24aeff06a0cc92dd9c3ea11be21
Issue Description:
Consider the following example:
The `case nil, _:` case appears to cover cases where `arg1` is `nil` and `arg2` is anything. However, because `nil` and `_` are treated as two separate patterns, this will actually cover all values for `arg1` and `arg2` (which is why exhaustivity checking doesn't complain).
We may want to offer a warning here (along with the appropriate fix-its) that warns the user that they are not matching against `(nil, _)` as it might appear. The warning could be silenced by writing:
The text was updated successfully, but these errors were encountered: