-
-
Notifications
You must be signed in to change notification settings - Fork 349
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The following function has an exhaustive pattern match which is correctly identified as such:
f : [A, B], U8 -> Bool
f = \x, y ->
when x is
A -> Bool.true
B -> Bool.false
_ if y > 1 -> Bool.falseNote that the wildcard does not make this pattern exhaustive. This is already covered by the cases A and B.
When the wildcard pattern is moved in between the A and B patterns, the following code is still fine:
f : [A, B], U8 -> Bool
f = \x, y ->
when x is
A -> Bool.true
_ if y > 1 -> Bool.false
B -> Bool.falseHowever, when making the the wildcard pattern the first pattern of the match roc check incorrectly reports this as an error:
── UNSAFE PATTERN in src/Test.roc ──────────────────────────────────────────────
This when does not cover all the possibilities:
5│> when x is
6│> _ if y > 1 -> Bool.false
7│> A -> Bool.true
8│> B -> Bool.false
Other possibilities include:
_ (note the lack of an if clause)
I would have to crash if I saw one of those! Add branches for them!
────────────────────────────────────────────────────────────────────────────────
1 error and 0 warnings found in 42 ms
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working