mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Expand handling of guard_needs_parens
This commit is contained in:
parent
7f1b3449a6
commit
d42af0b763
7 changed files with 125 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
a =
|
||||
i
|
||||
#
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
when
|
||||
f
|
||||
is
|
||||
3 if (|t|
|
||||
m
|
||||
%
|
||||
when
|
||||
f
|
||||
is
|
||||
z ->
|
||||
e
|
||||
z) -> m
|
|
@ -0,0 +1,93 @@
|
|||
@0-40 SpaceAfter(
|
||||
When(
|
||||
@5-6 SpaceAfter(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "f",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
[
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@10-11 SpaceBefore(
|
||||
NumLiteral(
|
||||
"3",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
value: @39-40 Var {
|
||||
module_name: "",
|
||||
ident: "m",
|
||||
},
|
||||
guard: Some(
|
||||
@14-37 Closure(
|
||||
[
|
||||
@15-16 Identifier {
|
||||
ident: "t",
|
||||
},
|
||||
],
|
||||
@18-37 BinOps(
|
||||
[
|
||||
(
|
||||
@18-19 Var {
|
||||
module_name: "",
|
||||
ident: "m",
|
||||
},
|
||||
@19-20 Percent,
|
||||
),
|
||||
],
|
||||
@20-37 When(
|
||||
@25-26 SpaceAfter(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "f",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
[
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@30-31 Identifier {
|
||||
ident: "z",
|
||||
},
|
||||
],
|
||||
value: @33-37 Apply(
|
||||
@33-34 Var {
|
||||
module_name: "",
|
||||
ident: "e",
|
||||
},
|
||||
[
|
||||
@36-37 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "z",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
guard: None,
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
when f
|
||||
is
|
||||
3 if\t->m%when f
|
||||
is z->e
|
||||
z->m
|
|
@ -777,6 +777,7 @@ mod test_snapshots {
|
|||
pass/when_if_guard.expr,
|
||||
pass/when_in_assignment.expr,
|
||||
pass/when_in_binop_in_assign_with_sneaky_newline.expr,
|
||||
pass/when_in_binop_in_closure_in_when_guard_wow_fuzzer.expr,
|
||||
pass/when_in_binops.expr,
|
||||
pass/when_in_closure_in_when_guard_wtf.expr,
|
||||
pass/when_in_function.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue