Fix when in when guard

This commit is contained in:
Joshua Warner 2025-01-10 22:36:23 -08:00
parent 586dc3486f
commit 903b792fd3
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
6 changed files with 117 additions and 5 deletions

View file

@ -4,6 +4,5 @@ di
when
b
is
7 -> 7e
)
7 -> 7e)
zl

View file

@ -0,0 +1,10 @@
when
f
is
s if (
when
0
is
z ->
f
z) -> m

View file

@ -0,0 +1,74 @@
@0-35 SpaceAfter(
When(
@5-6 SpaceAfter(
Var {
module_name: "",
ident: "f",
},
[
Newline,
],
),
[
WhenBranch {
patterns: [
@10-11 SpaceBefore(
Identifier {
ident: "s",
},
[
Newline,
],
),
],
value: @34-35 Var {
module_name: "",
ident: "m",
},
guard: Some(
@15-32 When(
@20-21 SpaceAfter(
Num(
"0",
),
[
Newline,
],
),
[
WhenBranch {
patterns: [
@25-26 Identifier {
ident: "z",
},
],
value: @28-32 Apply(
@28-29 Var {
module_name: "",
ident: "f",
},
[
@31-32 SpaceBefore(
Var {
module_name: "",
ident: "z",
},
[
Newline,
],
),
],
Space,
),
guard: None,
},
],
),
),
},
],
),
[
Newline,
],
)

View file

@ -0,0 +1,5 @@
when f
is
s if when 0
is z->f
z->m

View file

@ -764,6 +764,7 @@ mod test_snapshots {
pass/when_in_list.expr,
pass/when_in_parens.expr,
pass/when_in_parens_indented.expr,
pass/when_in_when_guard_wtf.expr,
pass/when_newline_after_condition.expr,
pass/when_newline_before_is_and_in_branch_parens.expr,
pass/when_result_list.expr,