mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-22 09:31:43 +00:00
Fix pnc apply in unary negate
This commit is contained in:
parent
05033ac40b
commit
2bd03ef16b
5 changed files with 46 additions and 6 deletions
|
@ -262,11 +262,8 @@ fn format_expr_only(
|
|||
|
||||
let before_all_newlines = lifted.before.iter().all(|s| s.is_newline());
|
||||
|
||||
let needs_newline = !before_all_newlines
|
||||
|| match &lifted.item {
|
||||
Expr::Str(text) => is_str_multiline(text),
|
||||
_ => false,
|
||||
};
|
||||
let needs_newline =
|
||||
!before_all_newlines || term_starts_with_multiline_str(&lifted.item);
|
||||
|
||||
let needs_parens = (needs_newline
|
||||
&& matches!(unary_op.value, called_via::UnaryOp::Negate))
|
||||
|
@ -369,6 +366,14 @@ fn format_expr_only(
|
|||
}
|
||||
}
|
||||
|
||||
fn term_starts_with_multiline_str(expr: &Expr<'_>) -> bool {
|
||||
match expr {
|
||||
Expr::Str(text) => is_str_multiline(text),
|
||||
Expr::PncApply(inner, _) => term_starts_with_multiline_str(&inner.value),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn prepare_expr_field_collection<'a>(
|
||||
arena: &'a Bump,
|
||||
items: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,
|
||||
|
@ -635,7 +640,9 @@ fn requires_space_after_unary(item: &Expr<'_>) -> bool {
|
|||
Expr::RecordAccess(inner, _field) | Expr::TupleAccess(inner, _field) => {
|
||||
requires_space_after_unary(inner)
|
||||
}
|
||||
Expr::Apply(inner, _, _) => requires_space_after_unary(&inner.value),
|
||||
Expr::Apply(inner, _, _) | Expr::PncApply(inner, _) => {
|
||||
requires_space_after_unary(&inner.value)
|
||||
}
|
||||
Expr::TrySuffix(expr) => requires_space_after_unary(expr),
|
||||
Expr::SpaceAfter(inner, _) | Expr::SpaceBefore(inner, _) => {
|
||||
requires_space_after_unary(inner)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue