Skip to content

Commit

Permalink
fix corner case in collapse_vars (#3574)
Browse files Browse the repository at this point in the history
fixes #3573
  • Loading branch information
alexlamsl committed Nov 7, 2019
1 parent 61a0dad commit 87e67ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -1283,6 +1283,7 @@ merge(Compressor.prototype, {
}
branch.expression = branch.expression.transform(scanner);
if (!replace_all) break;
scan_rhs = false;
}
}
abort = true;
Expand Down
33 changes: 33 additions & 0 deletions test/compress/collapse_vars.js
Expand Up @@ -6435,3 +6435,36 @@ call_assign_order: {
}
expect_stdout: "PASS PASS"
}

issue_3573: {
options = {
collapse_vars: true,
}
input: {
var c = 0;
(function(b) {
while (--b) {
b = NaN;
switch (0 / this < 0) {
case c++, false:
case c++, NaN:
}
}
})(3);
console.log(c);
}
expect: {
var c = 0;
(function(b) {
while (--b) {
b = NaN;
switch (0 / this < 0) {
case c++, false:
case c++, NaN:
}
}
})(3);
console.log(c);
}
expect_stdout: "1"
}

0 comments on commit 87e67ec

Please sign in to comment.