fix corner case in collapse_vars (#4733)

fixes #4732
This commit is contained in:
Alex Lam S.L
2021-03-04 09:13:54 +00:00
committed by GitHub
parent 20be5209c0
commit cb50a2d192
2 changed files with 50 additions and 1 deletions

View File

@@ -8756,3 +8756,51 @@ issue_4586_2: {
}
expect_stdout: "PASS"
}
issue_4732_1: {
options = {
booleans: true,
collapse_vars: true,
evaluate: true,
reduce_vars: true,
unused: true,
}
input: {
var a = 0;
(function(b) {
var b = a++;
var c = b ? b && console.log("PASS") : 0;
})(a++);
}
expect: {
var a = 0;
(function(b) {
(b = a++) && (b && console.log("PASS"));
})(a++);
}
expect_stdout: "PASS"
}
issue_4732_2: {
options = {
collapse_vars: true,
conditionals: true,
evaluate: true,
reduce_vars: true,
unused: true,
}
input: {
var a = 0;
(function(b) {
var b = a++;
var c = b ? b && console.log("PASS") : 0;
})(a++);
}
expect: {
var a = 0;
(function(b) {
(b = a++) && b && console.log("PASS");
})(a++);
}
expect_stdout: "PASS"
}