aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-06-07 06:48:29 +0100
committerGitHub <noreply@github.com>2020-06-07 13:48:29 +0800
commitaa37b196989edc13988ab225e4a7c954565e39eb (patch)
tree03250f3cc015f469f142da30ae9206310c131940
parent02e889e44996e9215fbbb4997c635518334df1c4 (diff)
downloadtracifyjs-aa37b196989edc13988ab225e4a7c954565e39eb.tar.gz
tracifyjs-aa37b196989edc13988ab225e4a7c954565e39eb.zip
fix corner case in `unused` (#3963)
fixes #3962
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/drop-unused.js65
2 files changed, 66 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 6aa81a52..749abef5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4521,7 +4521,7 @@ merge(Compressor.prototype, {
var index = indexOf_assign(sym, def);
if (index >= 0) assign_in_use[sym.id][index] = assign;
sym.eliminated++;
- return assign.transform(tt);
+ return assign;
}));
} else if (head.length > 0 || tail.length > 0) {
node.definitions = head.concat(tail);
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index a4a8595b..8c912a57 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -2690,3 +2690,68 @@ issue_3956: {
"1",
]
}
+
+issue_3962_1: {
+ options = {
+ evaluate: true,
+ keep_fargs: "strict",
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 0;
+ function f(b, c) {
+ do {
+ var d = console + e, e = 0..toString() === b;
+ } while (0);
+ if (c) console.log("PASS");
+ }
+ var a = f(a--, 1);
+ a;
+ }
+ expect: {
+ var a = 0;
+ a = (function(c) {
+ do {
+ console;
+ 0..toString();
+ } while (0);
+ if (c) console.log("PASS");
+ })((a--, 1));
+ void 0;
+ }
+ expect_stdout: "PASS"
+}
+
+issue_3962_2: {
+ options = {
+ keep_fargs: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 0;
+ function f(b, c) {
+ do {
+ var d = console + e, e = 0..toString() === b;
+ } while (0);
+ if (c) console.log("PASS");
+ }
+ var a = f(a--, 1);
+ a;
+ }
+ expect: {
+ var a = 0;
+ a = (function(c) {
+ do {
+ console;
+ 0..toString();
+ } while (0);
+ if (c) console.log("PASS");
+ })((a--, 1));
+ }
+ expect_stdout: "PASS"
+}