Add boolean flag to Expr::If for indented else statement

This commit is contained in:
snobee 2024-09-05 12:37:51 -07:00
parent 00572cbc83
commit a7afac7ac7
No known key found for this signature in database
GPG key ID: 77D517A21B16CC87
8 changed files with 136 additions and 47 deletions

View file

@ -796,7 +796,15 @@ impl<'a> Normalize<'a> for Expr<'a> {
Expr::UnaryOp(a, b) => {
Expr::UnaryOp(arena.alloc(a.normalize(arena)), b.normalize(arena))
}
Expr::If(a, b) => Expr::If(a.normalize(arena), arena.alloc(b.normalize(arena))),
Expr::If {
if_thens,
final_else,
indented_else,
} => Expr::If {
if_thens: if_thens.normalize(arena),
final_else: arena.alloc(final_else.normalize(arena)),
indented_else,
},
Expr::When(a, b) => Expr::When(arena.alloc(a.normalize(arena)), b.normalize(arena)),
Expr::ParensAround(a) => {
// The formatter can remove redundant parentheses, so also remove these when normalizing for comparison.