diff options
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 7e55da5a..03587359 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1367,7 +1367,7 @@ merge(Compressor.prototype, { if (replace_all) return false; return node instanceof AST_SymbolRef && !node.is_declared(compressor) - && !(parent instanceof AST_Assign && parent.left === node); + && !(parent instanceof AST_Assign && parent.operator == "=" && parent.left === node); } function in_conditional(node, parent) { diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index a5975279..c3832d43 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -7464,3 +7464,30 @@ issue_3651: { } expect_stdout: "PASS" } + +issue_3671: { + options = { + collapse_vars: true, + } + input: { + var a = 0; + try { + a++; + A += 0; + a = 1 + a; + } catch (e) { + console.log(a); + } + } + expect: { + var a = 0; + try { + a++; + A += 0; + a = 1 + a; + } catch (e) { + console.log(a); + } + } + expect_stdout: "1" +} |