mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
Simplify: left.rhs * right
is only safe when operators are the same
This commit is contained in:
parent
b5bbbc0cd6
commit
07bf194e61
@ -443,9 +443,8 @@ fn fold_bin(
|
||||
op: left_op,
|
||||
right: left_rhs,
|
||||
}) => {
|
||||
let v = perform_arithmetic_op(op, &left_rhs, &right);
|
||||
match v {
|
||||
Known(value) => {
|
||||
if left_op == op {
|
||||
if let Known(value) = perform_arithmetic_op(op, &left_rhs, &right) {
|
||||
return Expr::Bin(BinExpr {
|
||||
span,
|
||||
left: left_lhs,
|
||||
@ -453,15 +452,13 @@ fn fold_bin(
|
||||
right: box Expr::Lit(Lit::Num(Number { value, span })),
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
left = box Expr::Bin(BinExpr {
|
||||
left: left_lhs,
|
||||
op: left_op,
|
||||
span: left_span,
|
||||
right: left_rhs,
|
||||
})
|
||||
}
|
||||
}
|
||||
left = box Expr::Bin(BinExpr {
|
||||
left: left_lhs,
|
||||
op: left_op,
|
||||
span: left_span,
|
||||
right: left_rhs,
|
||||
})
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user