diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-19 01:33:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 09:33:57 +0800 |
commit | 90ec46824063450d88e04235df276a89e7025b77 (patch) | |
tree | efe23fbe1a8b249abe28f358a8758fb9c5a3c0c1 | |
parent | 994293e97229110f676dc72ad68b6b2d8a015394 (diff) | |
download | tracifyjs-90ec46824063450d88e04235df276a89e7025b77.tar.gz tracifyjs-90ec46824063450d88e04235df276a89e7025b77.zip |
fix corner case in `dead_code` (#4571)
fixes #4570
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/dead-code.js | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index e33f4f3f..21072f0c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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++); diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index cfbc6fae..1720a0dc 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -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" +} |