fix corner case in join_vars (#3796)

fixes #3795
This commit is contained in:
Alex Lam S.L
2020-04-18 11:08:05 +01:00
committed by GitHub
parent 708973e51d
commit b38838c6bf
2 changed files with 35 additions and 1 deletions

View File

@@ -782,3 +782,36 @@ issue_3791_2: {
}
expect_stdout: "function"
}
issue_3795: {
options = {
collapse_vars: true,
conditionals: true,
dead_code: true,
evaluate: true,
join_vars: true,
loops: true,
passes: 2,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var a = "FAIL";
function f(b) {
for (var i = 1; b && i; --i) return 0;
a = "PASS";
}
var c = f(a = "");
console.log(a);
}
expect: {
var a = "FAIL";
(function(b) {
a = "";
a = "PASS";
})();
console.log(a);
}
expect_stdout: "PASS"
}