mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 16:51:53 +03:00
add test case for exhaustiveness checking of list with rest and front and back
This commit is contained in:
parent
bf7be1533b
commit
9cf0d5366f
@ -12596,6 +12596,47 @@ In roc, functions are always written as a lambda, like{}
|
||||
"###
|
||||
);
|
||||
|
||||
test_no_problem!(
|
||||
list_match_spread_required_front_back,
|
||||
indoc!(
|
||||
r#"
|
||||
l : List [A, B]
|
||||
|
||||
when l is
|
||||
[A, ..] -> ""
|
||||
[.., A] -> ""
|
||||
[..] -> ""
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
test_report!(
|
||||
list_match_spread_redundant_front_back,
|
||||
indoc!(
|
||||
r#"
|
||||
l : List [A]
|
||||
|
||||
when l is
|
||||
[A, ..] -> ""
|
||||
[.., A] -> ""
|
||||
[..] -> ""
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
── REDUNDANT PATTERN ───────────────────────────────────── /code/proj/Main.roc ─
|
||||
|
||||
The 2nd pattern is redundant:
|
||||
|
||||
6│ when l is
|
||||
7│ [A, ..] -> ""
|
||||
8│> [.., A] -> ""
|
||||
9│ [..] -> ""
|
||||
|
||||
Any value of this shape will be handled by a previous pattern, so this
|
||||
one should be removed.
|
||||
"###
|
||||
);
|
||||
|
||||
test_no_problem!(
|
||||
list_match_exhaustive_empty_and_rest_with_unary_head,
|
||||
indoc!(
|
||||
|
Loading…
Reference in New Issue
Block a user