fix(es/minifier): Always consider reassigned when inlining (#8168)

**Related issue:**

 - Closes #8161.
This commit is contained in:
Austaras 2023-10-24 05:23:29 +08:00 committed by GitHub
parent 76ba2434de
commit c26a2252b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,10 @@
function run(flag, output = "a output") {
if (flag === "b") {
output = "b output";
}
console.log(output);
}
run("a");
run("b");

View File

@ -0,0 +1,4 @@
function run(flag, output = "a output") {
"b" === flag && (output = "b output"), console.log(output);
}
run("a"), run("b");