fix corner case in collapse_vars (#4917)

fixes #4916
This commit is contained in:
Alex Lam S.L
2021-05-07 19:34:27 +01:00
committed by GitHub
parent ac1f7d689b
commit ee9ceb79ca
2 changed files with 27 additions and 1 deletions

View File

@@ -1490,7 +1490,7 @@ merge(Compressor.prototype, {
lhs = lhs.fixed_value(); lhs = lhs.fixed_value();
} }
if (!lhs) return true; if (!lhs) return true;
if (lhs.is_constant()) return true; if (lhs.tail_node().is_constant()) return true;
return is_lhs_read_only(lhs, compressor); return is_lhs_read_only(lhs, compressor);
} }
if (lhs instanceof AST_SymbolRef) { if (lhs instanceof AST_SymbolRef) {

View File

@@ -1703,3 +1703,29 @@ issue_4854: {
expect_stdout: "undefined" expect_stdout: "undefined"
node_version: ">=6" node_version: ">=6"
} }
issue_4916: {
options = {
collapse_vars: true,
pure_getters: "strict",
reduce_vars: true,
}
input: {
var log = console.log;
(function(b = "foo") {
b.value = "FAIL";
b;
log(b.value);
})();
}
expect: {
var log = console.log;
(function(b = "foo") {
b.value = "FAIL";
b;
log(b.value);
})();
}
expect_stdout: "undefined"
node_version: ">=6"
}