fix corner case in conditionals (#5667)

fixes #5666
This commit is contained in:
Alex Lam S.L
2022-09-17 03:42:32 +01:00
committed by GitHub
parent 001f6f9719
commit e4bff315eb
2 changed files with 61 additions and 13 deletions

View File

@@ -2878,3 +2878,53 @@ issue_5546_3: {
}
expect_stdout: "PASS"
}
issue_5666_1: {
options = {
conditionals: true,
reduce_vars: true,
unused: true,
}
input: {
var a;
(function() {
var b = a;
a ? a = b : (b++, a = b);
})();
console.log(a);
}
expect: {
var a;
(function() {
var b = a;
a = (a ? 0 : b++, b);
})();
console.log(a);
}
expect_stdout: "NaN"
}
issue_5666_2: {
options = {
conditionals: true,
reduce_vars: true,
unused: true,
}
input: {
var a = "foo";
(function() {
var b = a;
a ? (b++, a = b) : a = b;
})();
console.log(a);
}
expect: {
var a = "foo";
(function() {
var b = a;
a = (a ? b++ : 0, b);
})();
console.log(a);
}
expect_stdout: "NaN"
}