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

@ -1249,7 +1249,11 @@ pub fn canonicalize_expr<'a>(
output,
)
}
ast::Expr::If(if_thens, final_else_branch) => {
ast::Expr::If {
if_thens,
final_else: final_else_branch,
..
} => {
let mut branches = Vec::with_capacity(if_thens.len());
let mut output = Output::default();
@ -2560,7 +2564,11 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
.iter()
.all(|(loc_expr, _binop)| is_valid_interpolation(&loc_expr.value))
}
ast::Expr::If(branches, final_branch) => {
ast::Expr::If {
if_thens: branches,
final_else: final_branch,
..
} => {
is_valid_interpolation(&final_branch.value)
&& branches.iter().all(|(loc_before, loc_after)| {
is_valid_interpolation(&loc_before.value)