fix corner case in reduce_vars (#4031)

fixes #4030
This commit is contained in:
Alex Lam S.L
2020-07-31 01:05:09 +01:00
committed by GitHub
parent dfe47bcc42
commit ee632a5519
2 changed files with 27 additions and 1 deletions

View File

@@ -587,7 +587,10 @@ merge(Compressor.prototype, {
d.assignments++;
var fixed = d.fixed;
var value = eq ? node.right : node;
if (is_modified(compressor, tw, node, value, 0)) return;
if (is_modified(compressor, tw, node, value, 0)) {
d.fixed = false;
return;
}
var safe = eq || safe_to_read(tw, d);
node.right.walk(tw);
if (safe && safe_to_assign(tw, d)) {

View File

@@ -7383,3 +7383,26 @@ issue_3974: {
}
expect_stdout: "PASS"
}
issue_4030: {
options = {
collapse_vars: true,
evaluate: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var a;
{
delete (a = "PASS");
A = "PASS";
}
console.log(A);
}
expect: {
A = "PASS";
console.log("PASS");
}
expect_stdout: "PASS"
}