diff --git a/lib/compress.js b/lib/compress.js index 6473da50444..bcfee5a48d4 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1016,6 +1016,7 @@ Compressor.prototype.compress = function(node) { } function walk_prop(lhs) { + reset_flags(lhs); if (lhs instanceof AST_Dot) { walk_prop(lhs.expression); } else if (lhs instanceof AST_Sub) { diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 348d2c9eba4..002202617dc 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -7896,3 +7896,33 @@ issue_5434: { } expect_stdout: "PASS" } + +issue_5623: { + options = { + collapse_vars: true, + evaluate: true, + passes: 2, + reduce_vars: true, + side_effects: true, + toplevel: true, + } + input: { + var a = 0; + function f() { + var b = a; + a = b; + } + f && f((a++ && a).toString()); + console.log(a); + } + expect: { + var a = 0; + function f() { + var b; + a = a; + } + f((a++ && a).toString()); + console.log(a); + } + expect_stdout: "1" +}