mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(es/minifier): Always consider reassigned
when inlining (#8168)
**Related issue:** - Closes #8161.
This commit is contained in:
parent
76ba2434de
commit
c26a2252b6
@ -175,7 +175,7 @@ impl Optimizer<'_> {
|
||||
if is_inline_enabled
|
||||
&& usage.declared_count == 1
|
||||
&& usage.assign_count == 1
|
||||
&& (!usage.has_property_mutation || !usage.reassigned)
|
||||
&& !usage.reassigned
|
||||
&& match init {
|
||||
Expr::Ident(Ident { sym, .. }) if &**sym == "eval" => false,
|
||||
|
||||
|
10
crates/swc_ecma_minifier/tests/fixture/issues/8161/input.js
Normal file
10
crates/swc_ecma_minifier/tests/fixture/issues/8161/input.js
Normal file
@ -0,0 +1,10 @@
|
||||
function run(flag, output = "a output") {
|
||||
if (flag === "b") {
|
||||
output = "b output";
|
||||
}
|
||||
|
||||
console.log(output);
|
||||
}
|
||||
|
||||
run("a");
|
||||
run("b");
|
@ -0,0 +1,4 @@
|
||||
function run(flag, output = "a output") {
|
||||
"b" === flag && (output = "b output"), console.log(output);
|
||||
}
|
||||
run("a"), run("b");
|
Loading…
Reference in New Issue
Block a user