support safe reassignments in reduce_vars (#1823)

`var a=1;a=2;x(a)` => `x(2)`

fix pre-existing issues
- reference counting on assignment
- walking of anonymous functions
- chained assignment
This commit is contained in:
Alex Lam S.L
2017-04-18 13:38:42 +08:00
committed by GitHub
parent d1aa09c5c7
commit 5d9f1da3ab
3 changed files with 145 additions and 30 deletions

View File

@@ -1592,3 +1592,25 @@ var_side_effects_3: {
}
expect_stdout: true
}
reduce_vars_assign: {
options = {
collapse_vars: true,
reduce_vars: true,
}
input: {
!function() {
var a = 1;
a = [].length,
console.log(a);
}();
}
expect: {
!function() {
var a = 1;
a = [].length,
console.log(a);
}();
}
expect_stdout: "0"
}