Add tests for multiple rest pattern errors

This commit is contained in:
Ayaz Hafiz 2022-10-31 11:59:55 -05:00
parent b0a8b85de3
commit 058d1f0b5d
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -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!
"###
);
}