enhance dead_code (#3849)

This commit is contained in:
Alex Lam S.L
2020-05-05 22:02:35 +01:00
committed by GitHub
parent 66ab2df97f
commit 34ead0430b
2 changed files with 22 additions and 0 deletions

View File

@@ -7670,6 +7670,11 @@ merge(Compressor.prototype, {
if (is_reachable(scope, [ def ])) break; if (is_reachable(scope, [ def ])) break;
def.fixed = false; def.fixed = false;
return strip_assignment(); return strip_assignment();
} else if (parent instanceof AST_VarDef) {
if (parent.name.definition() !== def) continue;
if (in_try(level, parent)) break;
def.fixed = false;
return strip_assignment();
} }
} while (parent instanceof AST_Binary && parent.right === node } while (parent instanceof AST_Binary && parent.right === node
|| parent instanceof AST_Sequence && parent.tail_node() === node || parent instanceof AST_Sequence && parent.tail_node() === node

View File

@@ -1151,3 +1151,20 @@ issue_3830_6: {
} }
expect_stdout: "PASS" expect_stdout: "PASS"
} }
redundant_assignments: {
options = {
dead_code: true,
}
input: {
var a = a = "PASS", b = "FAIL";
b = b = "PASS";
console.log(a, b);
}
expect: {
var a = "PASS", b = "FAIL";
b = "PASS";
console.log(a, b);
}
expect_stdout: "PASS PASS"
}