fix parsing lists in tag patterns

This commit is contained in:
Luke Boswell 2024-04-21 13:27:50 +10:00
parent 4cf256c6b7
commit 6844df6c37
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
4 changed files with 59 additions and 0 deletions

View file

@ -205,6 +205,7 @@ fn loc_parse_tag_pattern_arg<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern
crate::pattern::record_pattern_help() crate::pattern::record_pattern_help()
)), )),
loc!(string_like_pattern_help()), loc!(string_like_pattern_help()),
loc!(specialize_err(EPattern::List, list_pattern_help())),
loc!(number_pattern_help()) loc!(number_pattern_help())
) )
} }

View file

@ -0,0 +1,54 @@
When(
@5-10 Apply(
@5-7 Tag(
"Ok",
),
[
@8-10 List(
[],
),
],
Space,
),
[
WhenBranch {
patterns: [
@18-23 SpaceBefore(
Apply(
@18-20 Tag(
"Ok",
),
[
@21-23 List(
[],
),
],
),
[
Newline,
],
),
],
value: @27-29 Record(
[],
),
guard: None,
},
WhenBranch {
patterns: [
@34-35 SpaceBefore(
Underscore(
"",
),
[
Newline,
],
),
],
value: @39-41 Record(
[],
),
guard: None,
},
],
)

View file

@ -0,0 +1,3 @@
when Ok [] is
Ok [] -> {}
_ -> {}

View file

@ -482,6 +482,7 @@ mod test_snapshots {
pass/when_in_function_python_style_indent.expr, pass/when_in_function_python_style_indent.expr,
pass/when_in_parens.expr, pass/when_in_parens.expr,
pass/when_in_parens_indented.expr, pass/when_in_parens_indented.expr,
pass/when_result_list.expr,
pass/when_with_alternative_patterns.expr, pass/when_with_alternative_patterns.expr,
pass/when_with_function_application.expr, pass/when_with_function_application.expr,
pass/when_with_negative_numbers.expr, pass/when_with_negative_numbers.expr,