diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-04 13:13:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 13:13:48 +0800 |
commit | 0e29ad5eb9d6267c32f8ffb327aa79478c15e69c (patch) | |
tree | 2424d4dadde6286702b9a6caec4999f1b463c8d0 /lib | |
parent | 0f2687ecfc6cdd3801f7726deec1c8cd4240a0da (diff) | |
download | tracifyjs-0e29ad5eb9d6267c32f8ffb327aa79478c15e69c.tar.gz tracifyjs-0e29ad5eb9d6267c32f8ffb327aa79478c15e69c.zip |
fix corner case in `evaluate` (#3569)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index d8ee2bd3..87671d8e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2881,6 +2881,7 @@ merge(Compressor.prototype, { if (!non_converting_binary[this.operator]) depth++; var left = this.left._eval(compressor, cached, depth); if (left === this.left) return this; + if (this.operator == (left ? "||" : "&&")) return left; var right = this.right._eval(compressor, cached, depth); if (right === this.right) return this; var result; @@ -3049,7 +3050,10 @@ merge(Compressor.prototype, { cached.push(node); }); }); - return stat.value ? stat.value._eval(compressor, cached, depth) : undefined; + if (!stat.value) return undefined; + var val = stat.value._eval(compressor, cached, depth); + if (val === stat.value) return this; + return val; } else if (compressor.option("unsafe") && exp instanceof AST_PropAccess) { var key = exp.property; if (key instanceof AST_Node) { |