aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-22 13:08:45 +0100
committerGitHub <noreply@github.com>2020-09-22 20:08:45 +0800
commit3472cf1a908f516d1f2dd69b773abc61d7019b44 (patch)
tree2b8dc719fb16781fcfcd798a7216e4bb0af5d098
parent6d4c0fa6fabd7c5c75be419ed166b326f3da6bf3 (diff)
downloadtracifyjs-3472cf1a908f516d1f2dd69b773abc61d7019b44.tar.gz
tracifyjs-3472cf1a908f516d1f2dd69b773abc61d7019b44.zip
fix corner case in `unused` (#4147)
fixes #4146
-rw-r--r--.github/workflows/ufuzz.yml2
-rw-r--r--lib/compress.js9
-rw-r--r--test/compress/drop-unused.js27
3 files changed, 32 insertions, 6 deletions
diff --git a/.github/workflows/ufuzz.yml b/.github/workflows/ufuzz.yml
index 88c235f1..64b45565 100644
--- a/.github/workflows/ufuzz.yml
+++ b/.github/workflows/ufuzz.yml
@@ -36,7 +36,7 @@ jobs:
npm config set update-notifier false
npm --version
while !(npm install); do echo "'npm install' failed - retrying..."; done
- PERIOD=-2000
+ PERIOD=-5000
if [[ $CAUSE == "schedule" ]]; then
PERIOD=`node test/ufuzz/actions $BASE_URL $TOKEN`
fi
diff --git a/lib/compress.js b/lib/compress.js
index 66ed1430..7b8c4c1e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6474,17 +6474,16 @@ merge(Compressor.prototype, {
side_effects.push(node);
args[pos++] = make_sequence(call, side_effects);
side_effects = [];
- } else if (!trim && fn.argnames[i].__unused) {
+ } else if (!trim) {
if (side_effects.length) {
- node = make_sequence(call, side_effects);
+ args[pos++] = make_sequence(call, side_effects);
side_effects = [];
} else {
- node = make_node(AST_Number, args[i], {
+ args[pos++] = make_node(AST_Number, args[i], {
value: 0
});
+ continue;
}
- args[pos++] = node;
- continue;
}
} else {
side_effects.push(args[i]);
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 219adc9e..0b76f6f6 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -2965,3 +2965,30 @@ issue_4144: {
}
expect_stdout: "PASS"
}
+
+issue_4146: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f(a, b) {
+ function g() {}
+ var a = g;
+ var c = b;
+ c.p;
+ console.log(typeof a);
+ }
+ f("FAIL", 42);
+ }
+ expect: {
+ (function(a, b) {
+ a = function () {};
+ var c = b;
+ c.p;
+ console.log(typeof a);
+ })(0, 42);
+ }
+ expect_stdout: "function"
+}