diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-06-02 16:50:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 23:50:40 +0800 |
commit | c97ad98f92282bfa52f7d89dd5703021df6bec29 (patch) | |
tree | 49a09ac7e20c9f23157db30a97b2bcf1acd6e5e6 | |
parent | b24eb22c6b0ebbb3ec0274d76571864762c6393f (diff) | |
download | tracifyjs-c97ad98f92282bfa52f7d89dd5703021df6bec29.tar.gz tracifyjs-c97ad98f92282bfa52f7d89dd5703021df6bec29.zip |
fix corner case in `evaluate` (#3946)
fixes #3944
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/evaluate.js | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 3728884f..cfe37d0b 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3308,7 +3308,7 @@ merge(Compressor.prototype, { } var op = this.operator; var node; - if (HOP(lhs, "_eval") || !(lhs instanceof AST_SymbolRef) || !lhs.fixed_value()) { + if (HOP(lhs, "_eval") || !(lhs instanceof AST_SymbolRef) || !lhs.fixed || !lhs.definition().fixed) { node = op == "=" ? this.right : make_node(AST_Binary, this, { operator: op.slice(0, -1), left: lhs, diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 6deabafa..4e3bc725 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2690,3 +2690,32 @@ issue_3937: { } expect_stdout: "124 124" } + +issue_3944: { + options = { + collapse_vars: true, + evaluate: true, + inline: true, + reduce_vars: true, + unused: true, + } + input: { + (function() { + function f() { + while (function() { + var a = 0 == (b && b.p), b = console.log(a); + }()); + f; + } + f(); + })(); + } + expect: { + void function f() { + while (a = 0 == (a = void 0), console.log(a), void 0); + var a; + f; + }(); + } + expect_stdout: "false" +} |