account for declaration assignment in collapse_vars (#2859)

fixes #2858
This commit is contained in:
Alex Lam S.L
2018-02-01 15:09:53 +08:00
committed by GitHub
parent 2a4c68be4f
commit 102f994b9d
2 changed files with 35 additions and 0 deletions

View File

@@ -4190,3 +4190,37 @@ return_3: {
}
expect_stdout: "0"
}
issue_2858: {
options = {
collapse_vars: true,
unused: true,
}
input: {
var b;
(function() {
function f() {
a++;
}
f();
var c = f();
var a = void 0;
c || (b = a);
})();
console.log(b);
}
expect: {
var b;
(function() {
function f() {
a++;
}
f();
var c = f();
var a = void 0;
c || (b = a);
})();
console.log(b);
}
expect_stdout: "undefined"
}