diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-01-07 20:06:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-07 20:06:25 +0800 |
commit | f5ceff6e4b94a032078b0730f91662ee62758eb4 (patch) | |
tree | 561f9a3eb863ca0117b15c7b568756d9ee74e492 | |
parent | 4d6771b9b1d89f0b49625795a92267d6e59dd064 (diff) | |
download | tracifyjs-f5ceff6e4b94a032078b0730f91662ee62758eb4.tar.gz tracifyjs-f5ceff6e4b94a032078b0730f91662ee62758eb4.zip |
fix corner case in `unused` (#3674)
fixes #3673
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 03587359..f5d60ffc 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4196,7 +4196,7 @@ merge(Compressor.prototype, { if (node instanceof AST_Assign) { if (node.write_only === "p" && node.right.may_throw_on_access(compressor)) return; var right = get_rhs(node); - if (init && node.write_only && node_def.scope === self && !right.has_side_effects(compressor)) { + if (init && node.write_only === true && node_def.scope === self && !right.has_side_effects(compressor)) { initializations.add(node_def.id, right); } else { right.walk(tw); diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index b61af07a..0691a180 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -2355,3 +2355,23 @@ issue_3664: { } expect_stdout: "PASS" } + +issue_3673: { + options = { + pure_getters: "strict", + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a; + (a = [ a ]).p = 42; + console.log("PASS"); + } + expect: { + var a; + (a = [ a ]).p = 42; + console.log("PASS"); + } + expect_stdout: "PASS" +} |