aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-24 00:38:40 +0100
committerGitHub <noreply@github.com>2020-05-24 07:38:40 +0800
commit2c4d7d66efca56d89bc4acbfec63ac034570bcaa (patch)
tree85787154f0128a8e3e6310d912f10138085e290d
parentd1cc5270a3c4e34f0e639a869ecd1df21cc62fe7 (diff)
downloadtracifyjs-2c4d7d66efca56d89bc4acbfec63ac034570bcaa.tar.gz
tracifyjs-2c4d7d66efca56d89bc4acbfec63ac034570bcaa.zip
fix corner case in `reduce_vars` (#3923)
fixes #3922
-rw-r--r--lib/compress.js3
-rw-r--r--test/compress/reduce_vars.js27
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index a03b14e9..644746e4 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -738,8 +738,7 @@ merge(Compressor.prototype, {
var value = iife.args[i];
d.fixed = function() {
var j = fn.argnames.indexOf(arg);
- if (j < 0) return value;
- return iife.args[j] || make_node(AST_Undefined, iife);
+ return (j < 0 ? value : iife.args[j]) || make_node(AST_Undefined, iife);
};
tw.loop_ids[d.id] = tw.in_loop;
mark(tw, d, true);
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 08accc45..94852d45 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -7095,3 +7095,30 @@ issue_3894: {
}
expect_stdout: "PASS"
}
+
+issue_3922: {
+ options = {
+ evaluate: true,
+ keep_fargs: "strict",
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (function(a) {
+ var b;
+ b && b[c];
+ a |= this;
+ console.log("PASS");
+ var c = a.undefined;
+ })();
+ }
+ expect: {
+ (function() {
+ 0;
+ console.log("PASS");
+ })();
+ }
+ expect_stdout: "PASS"
+}