Fix premature promotion in optimizer.
This commit is contained in:
parent
1aa1066b93
commit
7f84a9f42b
@ -848,8 +848,8 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
|
|||||||
Stmt::Expr(expr) => {
|
Stmt::Expr(expr) => {
|
||||||
optimize_expr(expr, state, false);
|
optimize_expr(expr, state, false);
|
||||||
|
|
||||||
if matches!(**expr, Expr::FnCall(..) | Expr::Stmt(..)) {
|
// Do not promote until the expression is fully optimized
|
||||||
state.set_dirty();
|
if !state.is_dirty() && matches!(**expr, Expr::FnCall(..) | Expr::Stmt(..)) {
|
||||||
*stmt = match *mem::take(expr) {
|
*stmt = match *mem::take(expr) {
|
||||||
// func(...);
|
// func(...);
|
||||||
Expr::FnCall(x, pos) => Stmt::FnCall(x, pos),
|
Expr::FnCall(x, pos) => Stmt::FnCall(x, pos),
|
||||||
@ -859,6 +859,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
|
|||||||
Expr::Stmt(x) => (*x).into(),
|
Expr::Stmt(x) => (*x).into(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
state.set_dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user