consolidate & enhance unused (#2439)

- defer declaration removal in `collapse_vars`
- account for `AST_SymbolFunarg` in deduplication
- private accounting for `collapse_vars`
- avoid issues with identity reference due to deep cloning

fixes #2437
This commit is contained in:
Alex Lam S.L
2017-11-06 14:25:10 +08:00
committed by GitHub
parent 2c2fd89e34
commit 6c45101870
4 changed files with 145 additions and 76 deletions

View File

@@ -2131,14 +2131,13 @@ redefine_farg_1: {
}
expect: {
function f(a) {
var a;
return typeof a;
}
function g() {
return"number";
return "number";
}
function h(a, b) {
var a = b;
a = b;
return typeof a;
}
console.log(f([]), g([]), h([]));
@@ -2173,10 +2172,9 @@ redefine_farg_2: {
}
expect: {
console.log(function(a) {
var a;
return typeof a;
}([]), "number",function(a, b) {
var a = b;
a = b;
return typeof a;
}([]));
}
@@ -2185,11 +2183,13 @@ redefine_farg_2: {
redefine_farg_3: {
options = {
cascade: true,
evaluate: true,
inline: true,
keep_fargs: false,
passes: 3,
passes: 2,
reduce_vars: true,
sequences: true,
side_effects: true,
toplevel: true,
unused: true,