diff options
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 25 | ||||
-rw-r--r-- | test/compress/functions.js | 4 |
3 files changed, 28 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index 815797ca..4c9540d9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1911,6 +1911,7 @@ merge(Compressor.prototype, { right: ref, }); } + ref.fixed = false; def.replaced++; return ref; } @@ -1991,6 +1992,7 @@ merge(Compressor.prototype, { && !compressor.exposed(def); value_def.last_ref = false; value_def.single_use = false; + CHANGED = true; } if (replaced && !remove_candidate(candidate)) statements.splice(stat_index, 1); } 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, |