mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 05:24:15 +00:00
Make sure to add parens if a PncApply dbg stmt becomes a space-separated Apply
This commit is contained in:
parent
0438c17503
commit
8deca25c5e
5 changed files with 45 additions and 1 deletions
|
|
@ -1340,9 +1340,16 @@ pub fn expr_lift_spaces<'a, 'b: 'a>(
|
||||||
|
|
||||||
let right_lifted = expr_lift_spaces_after(Parens::InOperator, arena, &right.value);
|
let right_lifted = expr_lift_spaces_after(Parens::InOperator, arena, &right.value);
|
||||||
|
|
||||||
|
let mut item =
|
||||||
|
Expr::BinOps(lefts, arena.alloc(Loc::at(right.region, right_lifted.item)));
|
||||||
|
|
||||||
|
if parens == Parens::InApply || parens == Parens::InApplyLastArg {
|
||||||
|
item = Expr::ParensAround(arena.alloc(item));
|
||||||
|
}
|
||||||
|
|
||||||
Spaces {
|
Spaces {
|
||||||
before,
|
before,
|
||||||
item: Expr::BinOps(lefts, arena.alloc(Loc::at(right.region, right_lifted.item))),
|
item,
|
||||||
after: right_lifted.after,
|
after: right_lifted.after,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
dbg (a / a)
|
||||||
|
d
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
@0-8 SpaceAfter(
|
||||||
|
DbgStmt {
|
||||||
|
first: @4-7 BinOps(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
@4-5 Var {
|
||||||
|
module_name: "",
|
||||||
|
ident: "a",
|
||||||
|
},
|
||||||
|
@5-6 Slash,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
@6-7 Var {
|
||||||
|
module_name: "",
|
||||||
|
ident: "a",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extra_args: [],
|
||||||
|
continuation: @9-10 SpaceBefore(
|
||||||
|
Var {
|
||||||
|
module_name: "",
|
||||||
|
ident: "d",
|
||||||
|
},
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
dbg(a/a)
|
||||||
|
d
|
||||||
|
|
@ -397,6 +397,7 @@ mod test_snapshots {
|
||||||
pass/dbg_double_newline.expr,
|
pass/dbg_double_newline.expr,
|
||||||
pass/dbg_extra_parens.expr,
|
pass/dbg_extra_parens.expr,
|
||||||
pass/dbg_newline_apply.expr,
|
pass/dbg_newline_apply.expr,
|
||||||
|
pass/dbg_pnc_a_over_a.expr,
|
||||||
pass/dbg_stmt.expr,
|
pass/dbg_stmt.expr,
|
||||||
pass/dbg_stmt_in_parens.expr,
|
pass/dbg_stmt_in_parens.expr,
|
||||||
pass/dbg_stmt_multiline.expr,
|
pass/dbg_stmt_multiline.expr,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue