Skip to content

Commit

Permalink
add test case for exhaustiveness checking of list with rest and front…
Browse files Browse the repository at this point in the history
… and back
  • Loading branch information
bhansconnect committed Nov 21, 2023
1 parent 550935e commit e3174f6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions crates/compiler/load/tests/test_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit e3174f6

Please sign in to comment.