Fix when indent in the presence of weird multiline patterns

This commit is contained in:
Joshua Warner 2024-12-13 11:05:16 -08:00
parent 1d51f5fbec
commit 02e07f95e7
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
6 changed files with 79 additions and 14 deletions

View file

@ -0,0 +1,5 @@
when 6 is
O #
B ->
when 6 is
1 -> O

View file

@ -0,0 +1,62 @@
@0-31 SpaceAfter(
When(
@5-6 Num(
"6",
),
[
WhenBranch {
patterns: [
@10-15 SpaceBefore(
Apply(
@10-11 Tag(
"O",
),
[
@14-15 SpaceBefore(
Tag(
"B",
),
[
LineComment(
"",
),
],
),
],
),
[
Newline,
],
),
],
value: @17-31 When(
@22-23 Num(
"6",
),
[
WhenBranch {
patterns: [
@27-28 SpaceBefore(
NumLiteral(
"1",
),
[
Newline,
],
),
],
value: @30-31 Tag(
"O",
),
guard: None,
},
],
),
guard: None,
},
],
),
[
Newline,
],
)

View file

@ -0,0 +1,4 @@
when 6 is
O#
B->when 6 is
1->O

View file

@ -500,6 +500,7 @@ mod test_snapshots {
pass/nested_if.expr,
pass/nested_list_comment_in_closure_arg.expr,
pass/nested_parens_in_pattern.expr,
pass/nested_when_comment_in_pat.expr,
pass/newline_after_equals.expr, // Regression test for https://github.com/roc-lang/roc/issues/51
pass/newline_after_mul.expr,
pass/newline_after_opt_field.expr,