From 9cf0d5366f0b9189618ad8bb571a3c72a61de8a5 Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Mon, 20 Nov 2023 19:59:52 -0800 Subject: [PATCH] add test case for exhaustiveness checking of list with rest and front and back --- crates/compiler/load/tests/test_reporting.rs | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index cf516a53e8..55352fbd36 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -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!(