fix corner case in collapse_vars (#3574)

fixes #3573
This commit is contained in:
Alex Lam S.L
2019-11-07 20:38:03 +08:00
committed by GitHub
parent 61a0dad9fe
commit 87e67ec299
2 changed files with 34 additions and 0 deletions

View File

@@ -1283,6 +1283,7 @@ merge(Compressor.prototype, {
}
branch.expression = branch.expression.transform(scanner);
if (!replace_all) break;
scan_rhs = false;
}
}
abort = true;

View File

@@ -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"
}