aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-01-01 20:24:30 +0800
committerGitHub <noreply@github.com>2020-01-01 20:24:30 +0800
commit746f5f6c62c113ce89981f70ec5de8c8b78016da (patch)
treea8fc4e98b0d7a8673a845c348031a477c7e84c9c
parentd83d3d741ac8ea41a3776c9ca8d60e752180d420 (diff)
downloadtracifyjs-746f5f6c62c113ce89981f70ec5de8c8b78016da.tar.gz
tracifyjs-746f5f6c62c113ce89981f70ec5de8c8b78016da.zip
fix corner case in `unused` (#3665)
fixes #3664
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/drop-unused.js20
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 2bbd9704..f3fe8a8e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3913,7 +3913,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_Assign) {
if (!in_use || node.left === sym && def.id in fixed_ids && fixed_ids[def.id] !== node) {
value = get_rhs(node);
- if (node.write_only) {
+ if (node.write_only === true) {
value = value.drop_side_effect_free(compressor) || make_node(AST_Number, node, {
value: 0
});
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 2e131f7d..b61af07a 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -2335,3 +2335,23 @@ function_parameter_ie8: {
}
expect_stdout: "PASS"
}
+
+issue_3664: {
+ options = {
+ pure_getters: "strict",
+ unused: true,
+ }
+ input: {
+ console.log(function() {
+ var a, b = (a = (a = [ b && console.log("FAIL") ]).p = 0, 0);
+ return "PASS";
+ }());
+ }
+ expect: {
+ console.log(function() {
+ var b = ([ b && console.log("FAIL") ].p = 0, 0);
+ return "PASS";
+ }());
+ }
+ expect_stdout: "PASS"
+}