mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Merge pull request #2113 from rtfeldman/joshuawarner32/fix-indentation-within-parens
Fix formatting of if as an left-hand-side of an operator
This commit is contained in:
commit
d37ddeb162
2 changed files with 10 additions and 0 deletions
|
@ -1098,6 +1098,7 @@ fn sub_expr_requests_parens(expr: &Expr<'_>) -> bool {
|
|||
BinOp::Pizza | BinOp::Assignment | BinOp::HasType | BinOp::Backpassing => false,
|
||||
})
|
||||
}
|
||||
Expr::If(_, _) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2310,6 +2310,15 @@ mod test_fmt {
|
|||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binop_if() {
|
||||
expr_formats_same(indoc!(
|
||||
r#"
|
||||
5 * (if x > 0 then 1 else 2)
|
||||
"#
|
||||
));
|
||||
}
|
||||
|
||||
// UNARY OP
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue