fix corner case in hoist_props

fixes #4985
This commit is contained in:
alexlamsl 2021-05-30 10:34:09 +08:00
parent b9d5bba5fb
commit 54ec27ff9a
2 changed files with 26 additions and 1 deletions

View File

@ -7432,7 +7432,8 @@ merge(Compressor.prototype, {
&& all(right.properties, can_hoist_property)
&& all(def.references, function(ref) {
return ref.fixed_value() === right;
});
})
&& can_drop_symbol(sym, compressor);
}
});

View File

@ -1546,3 +1546,27 @@ issue_4848: {
expect_stdout: "PASS"
node_version: ">=4"
}
issue_4985: {
options = {
hoist_props: true,
reduce_vars: true,
toplevel: true,
}
input: {
"use strict";
let a = { p: 42 };
console.log(function() {
a;
}());
}
expect: {
"use strict";
let a = { p: 42 };
console.log(function() {
a;
}());
}
expect_stdout: "undefined"
node_version: ">=4"
}