diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-05-15 15:34:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 22:34:14 +0800 |
commit | bbed9b13b12a5bdcaad414e4e2ccd469001eb0e7 (patch) | |
tree | 104a973abd605be5f83663c3cc66cd0d61b438ef | |
parent | 2cff7c94e843e72dee1adf6c826a190f0e156441 (diff) | |
download | tracifyjs-bbed9b13b12a5bdcaad414e4e2ccd469001eb0e7.tar.gz tracifyjs-bbed9b13b12a5bdcaad414e4e2ccd469001eb0e7.zip |
fix corner case in `collapse_vars` (#4936)
fixes #4935
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 6010752d..02c034f6 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1982,6 +1982,7 @@ merge(Compressor.prototype, { force_single = true; continue; } + if (replaced == assign_pos) assign_used = true; var def = lhs.definition(); abort = false; hit_index = 0; diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index be13cff8..83eccdf1 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -9220,3 +9220,28 @@ issue_4920: { } expect_stdout: "PASS" } + +issue_4935: { + options = { + collapse_vars: true, + reduce_vars: true, + toplevel: true, + } + input: { + var a = 1; + var b; + var c = b = a; + console || c(a++); + --b; + console.log(a, b); + } + expect: { + var a = 1; + var b; + var c = b = a; + console || a(a++); + --b; + console.log(a, b); + } + expect_stdout: "1 0" +} |