Skip to content

Commit

Permalink
fix corner case in reduce_vars (#5624)
Browse files Browse the repository at this point in the history
fixes #5623
  • Loading branch information
alexlamsl authored Aug 18, 2022
1 parent 9eea3a6 commit ac002b6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
30 changes: 30 additions & 0 deletions test/compress/reduce_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit ac002b6

Please sign in to comment.