fix corner case in collapse_vars (#4041)

fixes #4040
This commit is contained in:
Alex Lam S.L
2020-08-06 13:30:28 +01:00
committed by GitHub
parent 9b05494ebc
commit a8e286f7e1
2 changed files with 19 additions and 4 deletions

View File

@@ -1549,10 +1549,9 @@ merge(Compressor.prototype, {
return lvalues.has(node.name.name) || side_effects && may_modify(node.name);
}
var sym = is_lhs(node.left, node);
if (!sym) return false;
return lvalues.has(sym.name)
|| sym instanceof AST_PropAccess
|| read_toplevel && compressor.exposed(sym.definition());
if (sym instanceof AST_PropAccess) return true;
if (!(sym instanceof AST_SymbolRef)) return false;
return lvalues.has(sym.name) || read_toplevel && compressor.exposed(sym.definition());
}
function extract_args() {

View File

@@ -8375,3 +8375,19 @@ issue_4038: {
}
expect_stdout: "PASS"
}
issue_4040: {
options = {
collapse_vars: true,
toplevel: true,
}
input: {
var a = console.log("PASS") && a.p;
delete NaN;
}
expect: {
var a = console.log("PASS") && a.p;
delete NaN;
}
expect_stdout: "PASS"
}