diff options
-rw-r--r-- | lib/compress.js | 5 | ||||
-rw-r--r-- | test/compress/reduce_vars.js | 23 |
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index d439ed4c..792d5ab2 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -587,7 +587,10 @@ merge(Compressor.prototype, { d.assignments++; var fixed = d.fixed; var value = eq ? node.right : node; - if (is_modified(compressor, tw, node, value, 0)) return; + if (is_modified(compressor, tw, node, value, 0)) { + d.fixed = false; + return; + } var safe = eq || safe_to_read(tw, d); node.right.walk(tw); if (safe && safe_to_assign(tw, d)) { diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 9010fb1e..85969f90 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -7383,3 +7383,26 @@ issue_3974: { } expect_stdout: "PASS" } + +issue_4030: { + options = { + collapse_vars: true, + evaluate: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var a; + { + delete (a = "PASS"); + A = "PASS"; + } + console.log(A); + } + expect: { + A = "PASS"; + console.log("PASS"); + } + expect_stdout: "PASS" +} |