aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-18 01:41:10 +0100
committerGitHub <noreply@github.com>2020-05-18 08:41:10 +0800
commitf9b3198714f9d061531ddafca8385473ecafca2a (patch)
tree032d5bb5d6749e2dffac04867ccefc3cf401c865 /lib/compress.js
parent48b62393a4d947fe22d5516e53267a37245347c5 (diff)
downloadtracifyjs-f9b3198714f9d061531ddafca8385473ecafca2a.tar.gz
tracifyjs-f9b3198714f9d061531ddafca8385473ecafca2a.zip
fix corner case in `evaluate` (#3906)
fixes #3905
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 02d36d6c..d378e26e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3570,9 +3570,10 @@ merge(Compressor.prototype, {
}
var args = eval_args(this.args);
if (!args && !ignore_side_effects) return this;
- if (!stat.value) return;
+ var val = stat.value;
+ if (!val) return;
var cached_args = [];
- if (args && !all(fn.argnames, function(sym, i) {
+ if (!args || all(fn.argnames, function(sym, i) {
var value = args[i];
var def = sym.definition();
if (def.orig[def.orig.length - 1] !== sym) return false;
@@ -3583,15 +3584,15 @@ merge(Compressor.prototype, {
cached_args.push(node);
});
return true;
- }) && !ignore_side_effects) return this;
- fn.evaluating = true;
- var val = stat.value._eval(compressor, ignore_side_effects, cached, depth);
- delete fn.evaluating;
+ }) || ignore_side_effects) {
+ fn.evaluating = true;
+ val = val._eval(compressor, ignore_side_effects, cached, depth);
+ delete fn.evaluating;
+ }
cached_args.forEach(function(node) {
delete node._eval;
});
- if (val === stat.value) return this;
- return val;
+ return val === stat.value ? this : val;
} else if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
var key = exp.property;
if (key instanceof AST_Node) {