Skip to content

Commit

Permalink
fix corner case in dead_code (#4571)
Browse files Browse the repository at this point in the history
fixes #4570
  • Loading branch information
alexlamsl authored Jan 19, 2021
1 parent 994293e commit 90ec468
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -9987,7 +9987,7 @@ merge(Compressor.prototype, {
var scope = def.scope.resolve();
var local = scope === compressor.find_parent(AST_Lambda);
var level = 0, node;
parent = self;
parent = compressor.self();
do {
node = parent;
parent = compressor.parent(level++);
Expand Down
18 changes: 18 additions & 0 deletions test/compress/dead-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -1399,3 +1399,21 @@ issue_4366: {
expect_stdout: "PASS"
node_version: ">=4"
}

issue_4570: {
options = {
dead_code: true,
inline: true,
}
input: {
var a = function(b) {
return a += b;
}() ? 0 : a;
console.log(a);
}
expect: {
var a = (a += void 0) ? 0 : a;
console.log(a);
}
expect_stdout: "NaN"
}

0 comments on commit 90ec468

Please sign in to comment.