fix corner case in reduce_vars (#5047)

fixes #5046
This commit is contained in:
Alex Lam S.L
2021-07-04 06:45:09 +01:00
committed by GitHub
parent 972b9f0bef
commit f4ae267920
2 changed files with 32 additions and 7 deletions

View File

@@ -6285,3 +6285,34 @@ issue_5036: {
}
expect_stdout: "PASS"
}
issue_5046: {
options = {
conditionals: true,
evaluate: true,
keep_fnames: true,
passes: 2,
reduce_vars: true,
side_effects: true,
toplevel: true,
}
input: {
var a = 0;
if (a)
0();
else
(function f() {
f;
return a = "PASS";
})();
console.log(a);
}
expect: {
var a = 0;
(a ? 0 : function f() {
return a = "PASS";
})();
console.log(a);
}
expect_stdout: "PASS"
}