fix corner case in collapse_vars (#2909)

fixes #2908
This commit is contained in:
Alex Lam S.L
2018-02-13 01:41:22 +08:00
committed by GitHub
parent 0809699bdc
commit 0c4f315c02
2 changed files with 51 additions and 10 deletions

View File

@@ -4517,3 +4517,32 @@ issue_2891_2: {
}
expect_stdout: true
}
issue_2908: {
options = {
collapse_vars: true,
}
input: {
var a = 0, b = 0;
function f(c) {
if (1 == c) return;
a++;
if (2 == c) b = a;
}
f(0);
f(2);
console.log(b);
}
expect: {
var a = 0, b = 0;
function f(c) {
if (1 == c) return;
a++;
if (2 == c) b = a;
}
f(0);
f(2);
console.log(b);
}
expect_stdout: "2"
}