mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge pull request #7409 from joshuawarner32/fuzzing-bugs-5
Fix another batch of parsing/formatting bugs found in fuzzing
This commit is contained in:
commit
f7dbf850b9
31 changed files with 750 additions and 74 deletions
|
@ -291,7 +291,7 @@ fn format_expr_only(
|
|||
let inner_parens = if needs_parens {
|
||||
Parens::NotNeeded
|
||||
} else {
|
||||
Parens::InApply
|
||||
Parens::InApplyLastArg
|
||||
};
|
||||
|
||||
if !before_all_newlines {
|
||||
|
@ -1314,13 +1314,21 @@ pub fn expr_lift_spaces<'a, 'b: 'a>(
|
|||
after: right_lifted.after,
|
||||
}
|
||||
}
|
||||
Expr::UnaryOp(expr, op) => {
|
||||
let expr_lifted = expr_lift_spaces_after(Parens::InOperator, arena, &expr.value);
|
||||
Expr::UnaryOp(inner, op) => {
|
||||
if parens == Parens::InApply && matches!(inner.without_spaces(), Expr::Closure(..)) {
|
||||
return Spaces {
|
||||
before: &[],
|
||||
item: Expr::ParensAround(arena.alloc(*expr)),
|
||||
after: &[],
|
||||
};
|
||||
}
|
||||
|
||||
let inner_lifted = expr_lift_spaces_after(Parens::InOperator, arena, &inner.value);
|
||||
|
||||
Spaces {
|
||||
before: &[],
|
||||
item: Expr::UnaryOp(arena.alloc(Loc::at(expr.region, expr_lifted.item)), *op),
|
||||
after: expr_lifted.after,
|
||||
item: Expr::UnaryOp(arena.alloc(Loc::at(inner.region, inner_lifted.item)), *op),
|
||||
after: inner_lifted.after,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue