diff options
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0321a532..e3532fef 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1671,7 +1671,7 @@ merge(Compressor.prototype, { function symbol_in_lvalues(sym, parent) { var lvalue = lvalues[sym.name]; if (!lvalue) return; - if (lvalue !== lhs) return !(parent instanceof AST_Call && parent.expression === sym); + if (lvalue !== lhs) return true; scan_rhs = false; } diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 858d3d41..31978c29 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -6348,3 +6348,42 @@ issue_3526_2: { } expect_stdout: "PASS" } + +issue_3562: { + options = { + collapse_vars: true, + conditionals: true, + sequences: true, + } + input: { + function f(a) { + console.log("PASS", a); + } + function g(b) { + console.log("FAIL", b); + } + var h; + var c; + if (console) { + h = f; + c = "PASS"; + } else { + h = g; + c = "FAIL"; + } + h(c); + } + expect: { + function f(a) { + console.log("PASS", a); + } + function g(b) { + console.log("FAIL", b); + } + var h; + var c; + c = console ? (h = f, "PASS") : (h = g, "FAIL"), + h(c); + } + expect_stdout: "PASS PASS" +} |