fix corner case in collapse_vars (#5397)

fixes #5396
This commit is contained in:
Alex Lam S.L
2022-03-31 13:02:56 +01:00
committed by GitHub
parent e3d328f741
commit fb5e08e4ec
2 changed files with 59 additions and 29 deletions

View File

@@ -9947,3 +9947,35 @@ issue_5394: {
}
expect_stdout: "object"
}
issue_5396: {
options = {
collapse_vars: true,
merge_vars: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
var a, b;
function f() {}
b = 0;
new function g(c) {
var d = a && g(e), e = ++d, i = [ 42 ];
for (var j in i)
console.log("PASS"),
i;
}();
}
expect: {
var a, b;
function f() {}
b = 0;
(function g(c) {
a && g();
for (var j in [ 42 ])
console.log("PASS");
})();
}
expect_stdout: "PASS"
}