diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-08-25 10:23:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 17:23:36 +0800 |
commit | a31c27c7cf0c1543305c7710b139201850132e15 (patch) | |
tree | c77ff4a46e422c664ca7a348576190cc1e5204b0 | |
parent | 1caf7c7bd2160a5f249066bf62292f3589ceebb1 (diff) | |
download | tracifyjs-a31c27c7cf0c1543305c7710b139201850132e15.tar.gz tracifyjs-a31c27c7cf0c1543305c7710b139201850132e15.zip |
fix corner case in `collapse_vars` (#4071)
fixes #4070
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 4de587ae..3f0ea219 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1286,7 +1286,7 @@ merge(Compressor.prototype, { col: node.start.col }); if (candidate instanceof AST_UnaryPostfix) { - lhs.definition().fixed = false; + if (lhs instanceof AST_SymbolRef) lhs.definition().fixed = false; return make_node(AST_UnaryPrefix, candidate, candidate); } if (candidate instanceof AST_VarDef) { diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index c042f969..709fc6b7 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -8538,3 +8538,25 @@ issue_4051: { } expect_stdout: "undefined" } + +issue_4070: { + options = { + collapse_vars: true, + pure_getters: "strict", + reduce_vars: true, + } + input: { + console.log(function f() { + function g() {} + g.p++; + return f.p = g.p; + }()); + } + expect: { + console.log(function f() { + function g() {} + return f.p = ++g.p; + }()); + } + expect_stdout: "NaN" +} |