Skip to content

Commit

Permalink
fix corner case in collapse_vars (#3672)
Browse files Browse the repository at this point in the history
fixes #3671
  • Loading branch information
alexlamsl committed Jan 7, 2020
1 parent d171911 commit 4d6771b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -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) {
Expand Down
27 changes: 27 additions & 0 deletions test/compress/collapse_vars.js
Expand Up @@ -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"
}

0 comments on commit 4d6771b

Please sign in to comment.