Open imclerran opened 2 weeks ago
The following is also "not exhaustive":
when (list1, list2) is
([], _) -> Task.ok {}
(_, []) -> Task.ok {}
([_], [_]) -> Task.ok {}
([_], [_, ..]) -> Task.ok {}
([_, ..], [_]) -> Task.ok {}
([_, ..], [_,..]) -> Task.ok {}
Same applies for recods, the following is "not exhaustive":
when { l1: list1, l2: list2 } is
{ l1: [], l2: _ } -> Task.ok {}
{ l1: _, l2: [] } -> Task.ok {}
{ l1: [_], l2: [_] } -> Task.ok {}
{ l1: [_], l2: [_, ..] } -> Task.ok {}
{ l1: [_, ..], l2: [_] } -> Task.ok {}
{ l1: [_, ..], l2: [_, ..] } -> Task.ok {}
Another problem in checking exhaustiveness with record pattern matching:
If I omit the underscore, like follows, it says that patterns are redundant that actually check different fields:
when { l1: list1, l2: list2 } is
{ l1: [] } -> Task.ok {}
{ l2: [] } -> Task.ok {}
#...
Error message:
The 2nd pattern is redundant:
11│ when { l1: list1, l2: list2 } is
12│ { l1: [] } -> Task.ok {}
13│> { l2: [] } -> Task.ok {}
The following should be exhaustive, but roc says that it is not.
Error message:
The only way I have found to avoid this "non exhaustiveness" message is to include a pattern at the end of my when block which matches on all cases, ie: