aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-13 16:44:54 +0100
committerGitHub <noreply@github.com>2020-05-13 23:44:54 +0800
commitfe2f1965d6efcd1807eea087708ffdb9a5798db0 (patch)
treec81b12f827e8e39e1b4d8bb3024a2fde1752fd41 /lib/compress.js
parent30ed8f558038ea1017ecd8cb4a02851eaed92ac0 (diff)
downloadtracifyjs-fe2f1965d6efcd1807eea087708ffdb9a5798db0.tar.gz
tracifyjs-fe2f1965d6efcd1807eea087708ffdb9a5798db0.zip
fix corner case in `reduce_vars` (#3895)
fixes #3894
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index f7c0af30..8cf7262a 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -741,6 +741,11 @@ merge(Compressor.prototype, {
if (j < 0) return value;
return iife.args[j] || make_node(AST_Undefined, iife);
};
+ d.fixed.reduce_arg = function() {
+ var j = fn.argnames.indexOf(arg);
+ if (j < 0 || j >= iife.args.length) return;
+ iife.args[j] = make_node(AST_Number, iife.args[j], { value: 0 });
+ };
tw.loop_ids[d.id] = tw.in_loop;
mark(tw, d, true);
} else {
@@ -7566,6 +7571,7 @@ merge(Compressor.prototype, {
}));
} else {
value = fixed.optimize(compressor);
+ if (def.fixed.reduce_arg) def.fixed.reduce_arg();
}
def.replaced++;
return value;