diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-05-04 09:33:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 16:33:52 +0800 |
commit | 3094eaaa89b3993051e307804dd5daee1cf7146a (patch) | |
tree | 100cd1d9e3af31598592b228496745c279b9e04b /test/compress | |
parent | ce3c35fa8b4c8e9a777d19220915880cdd45f3fb (diff) | |
download | tracifyjs-3094eaaa89b3993051e307804dd5daee1cf7146a.tar.gz tracifyjs-3094eaaa89b3993051e307804dd5daee1cf7146a.zip |
fix corner case in `collapse_vars` (#4909)
fixes #4908
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 25 | ||||
-rw-r--r-- | test/compress/functions.js | 4 |
2 files changed, 26 insertions, 3 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index f8a8a31a..0c23ad8c 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -9049,7 +9049,7 @@ issue_4874: { } expect: { var a; - null; + a = null; (function(b) { for (var c in a && a[console.log("PASS")]) console; @@ -9107,3 +9107,26 @@ issue_4895: { } expect_stdout: "42 42" } + +issue_4908: { + options = { + collapse_vars: true, + join_vars: true, + reduce_vars: true, + toplevel: true, + } + input: { + var a = 0; + var b; + console || a++; + var c = d = a, d = [ c && c, d += 42 ]; + console.log(d[1]); + } + expect: { + var a = 0, b; + console || a++; + var c = d = a, d = [ d && d, d += 42 ]; + console.log(d[1]); + } + expect_stdout: "42" +} diff --git a/test/compress/functions.js b/test/compress/functions.js index 5713a37b..baab29d2 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -6107,7 +6107,7 @@ reduce_cross_reference_2: { reduce_cross_reference_2_toplevel: { options = { collapse_vars: true, - passes: 2, + passes: 3, pure_getters: "strict", reduce_vars: true, sequences: true, @@ -6150,7 +6150,7 @@ reduce_cross_reference_3: { reduce_cross_reference_3_toplevel: { options = { collapse_vars: true, - passes: 2, + passes: 3, pure_getters: "strict", reduce_vars: true, sequences: true, |