diff options
-rw-r--r-- | lib/compress.js | 5 | ||||
-rw-r--r-- | test/compress/functions.js | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 454ce945..999e03c4 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4841,6 +4841,11 @@ merge(Compressor.prototype, { for (var j = 0, defs = stat.definitions.length; j < defs; j++) { var var_def = stat.definitions[j]; var name = var_def.name; + var redef = name.definition().redefined(); + if (redef) { + name = name.clone(); + name.thedef = redef; + } append_var(decls, expressions, name, var_def.value); if (in_loop && all(fn.argnames, function(argname) { return argname.name != name.name; diff --git a/test/compress/functions.js b/test/compress/functions.js index 471ebf7f..650254f4 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2267,3 +2267,39 @@ issue_3054: { } expect_stdout: "true true" } + +issue_3076: { + options = { + dead_code: true, + inline: true, + sequences: true, + unused: true, + } + input: { + var c = "PASS"; + (function(b) { + var n = 2; + while (--b + function() { + e && (c = "FAIL"); + e = 5; + return 1; + try { + var a = 5; + } catch (e) { + var e; + } + }().toString() && --n > 0); + })(2); + console.log(c); + } + expect: { + var c = "PASS"; + (function(b) { + var n = 2; + while (--b + (e = void 0, e && (c = "FAIL"), e = 5, 1).toString() && --n > 0); + var e; + })(2), + console.log(c); + } + expect_stdout: "PASS" +} |