mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Normalize return's 'after'
This commit is contained in:
parent
17849ca556
commit
2857833c35
5 changed files with 73 additions and 1 deletions
|
@ -1116,7 +1116,7 @@ pub fn expr_lift_spaces<'a, 'b: 'a>(
|
|||
after: body_lifted.after,
|
||||
}
|
||||
}
|
||||
Expr::If { .. } | Expr::When(_, _) | Expr::Return(_, _) => {
|
||||
Expr::If { .. } | Expr::When(_, _) => {
|
||||
if parens == Parens::InApply || parens == Parens::InApplyLastArg {
|
||||
Spaces {
|
||||
before: &[],
|
||||
|
@ -1131,6 +1131,34 @@ pub fn expr_lift_spaces<'a, 'b: 'a>(
|
|||
}
|
||||
}
|
||||
}
|
||||
Expr::Return(val, opt_after) => {
|
||||
if parens == Parens::InApply || parens == Parens::InApplyLastArg {
|
||||
Spaces {
|
||||
before: &[],
|
||||
item: Expr::ParensAround(arena.alloc(*expr)),
|
||||
after: &[],
|
||||
}
|
||||
} else if let Some(after) = opt_after {
|
||||
let after_lifted = expr_lift_spaces_after(Parens::NotNeeded, arena, &after.value);
|
||||
|
||||
Spaces {
|
||||
before: &[],
|
||||
item: Expr::Return(
|
||||
val,
|
||||
Some(arena.alloc(Loc::at(after.region, after_lifted.item))),
|
||||
),
|
||||
after: after_lifted.after,
|
||||
}
|
||||
} else {
|
||||
let val_lifted = expr_lift_spaces_after(Parens::NotNeeded, arena, &val.value);
|
||||
|
||||
Spaces {
|
||||
before: &[],
|
||||
item: Expr::Return(arena.alloc(Loc::at(val.region, val_lifted.item)), None),
|
||||
after: val_lifted.after,
|
||||
}
|
||||
}
|
||||
}
|
||||
Expr::Backpassing(pats, call, continuation) => {
|
||||
let pats = arena.alloc_slice_copy(pats);
|
||||
let before = if let Some(first) = pats.first_mut() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue