compress duplicated variable definitions (#1817)

These are surprisingly common, as people reuse the same variable name within loops or switch branches.
This commit is contained in:
Alex Lam S.L
2017-04-17 17:11:29 +08:00
committed by GitHub
parent 71a8d0d236
commit 4ffb6fce76
4 changed files with 73 additions and 11 deletions

View File

@@ -1029,3 +1029,30 @@ delete_assign_2: {
}
expect_stdout: true
}
drop_var: {
options = {
toplevel: true,
unused: true,
}
input: {
var a;
console.log(a, b);
var a = 1, b = 2;
console.log(a, b);
var a = 3;
console.log(a, b);
}
expect: {
console.log(a, b);
var a = 1, b = 2;
console.log(a, b);
a = 3;
console.log(a, b);
}
expect_stdout: [
"undefined undefined",
"1 2",
"3 2",
]
}