mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Add tests for multiple rest pattern errors
This commit is contained in:
parent
b0a8b85de3
commit
058d1f0b5d
1 changed files with 69 additions and 1 deletions
|
@ -11714,7 +11714,7 @@ All branches in an `if` must have the same type!
|
|||
list_pattern_weird_rest_pattern,
|
||||
indoc!(
|
||||
r#"
|
||||
when [] is
|
||||
when [] is
|
||||
[...] -> ""
|
||||
"#
|
||||
),
|
||||
|
@ -11753,4 +11753,72 @@ All branches in an `if` must have the same type!
|
|||
safely.
|
||||
"###
|
||||
);
|
||||
|
||||
test_report!(
|
||||
multiple_list_patterns_start_and_end,
|
||||
indoc!(
|
||||
r#"
|
||||
when [] is
|
||||
[.., A, ..] -> ""
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
── MULTIPLE LIST REST PATTERNS ─────────────────────────── /code/proj/Main.roc ─
|
||||
|
||||
This list pattern match has multiple rest patterns:
|
||||
|
||||
5│ [.., A, ..] -> ""
|
||||
^^
|
||||
|
||||
I only support compiling list patterns with one .. pattern! Can you
|
||||
remove this additional one?
|
||||
|
||||
── UNSAFE PATTERN ──────────────────────────────────────── /code/proj/Main.roc ─
|
||||
|
||||
This `when` does not cover all the possibilities:
|
||||
|
||||
4│> when [] is
|
||||
5│> [.., A, ..] -> ""
|
||||
|
||||
Other possibilities include:
|
||||
|
||||
_
|
||||
|
||||
I would have to crash if I saw one of those! Add branches for them!
|
||||
"###
|
||||
);
|
||||
|
||||
test_report!(
|
||||
multiple_list_patterns_in_a_row,
|
||||
indoc!(
|
||||
r#"
|
||||
when [] is
|
||||
[A, .., .., B] -> ""
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
── MULTIPLE LIST REST PATTERNS ─────────────────────────── /code/proj/Main.roc ─
|
||||
|
||||
This list pattern match has multiple rest patterns:
|
||||
|
||||
5│ [A, .., .., B] -> ""
|
||||
^^
|
||||
|
||||
I only support compiling list patterns with one .. pattern! Can you
|
||||
remove this additional one?
|
||||
|
||||
── UNSAFE PATTERN ──────────────────────────────────────── /code/proj/Main.roc ─
|
||||
|
||||
This `when` does not cover all the possibilities:
|
||||
|
||||
4│> when [] is
|
||||
5│> [A, .., .., B] -> ""
|
||||
|
||||
Other possibilities include:
|
||||
|
||||
_
|
||||
|
||||
I would have to crash if I saw one of those! Add branches for them!
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue