mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
Make sure unary operators around function calls get parens
This commit is contained in:
parent
0a58d6e60e
commit
e9d22699ed
@ -258,7 +258,7 @@ impl<'a> Formattable<'a> for Expr<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
sub_expr.format_with_options(buf, parens, newlines, indent);
|
||||
sub_expr.format_with_options(buf, Parens::InApply, newlines, indent);
|
||||
}
|
||||
AccessorFunction(key) => {
|
||||
buf.push('.');
|
||||
|
@ -2324,6 +2324,25 @@ mod test_fmt {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unary_call_parens() {
|
||||
expr_formats_same(indoc!(
|
||||
r#"
|
||||
!(f 1)
|
||||
"#
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unary_call_no_parens() {
|
||||
// TIL: Negating a function "does what you might expect"... which is cool!
|
||||
expr_formats_same(indoc!(
|
||||
r#"
|
||||
!f 1
|
||||
"#
|
||||
));
|
||||
}
|
||||
|
||||
// BINARY OP
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user