improve collapse_vars (#2591)

- handle single-use assignments other than `AST_VarDef`
- scan `AST_Call` for candidates
This commit is contained in:
Alex Lam S.L
2017-12-14 15:31:35 +08:00
committed by GitHub
parent d18979bb23
commit 738fd52bc4
2 changed files with 26 additions and 4 deletions

View File

@@ -1993,10 +1993,8 @@ undeclared: {
}
expect: {
function f(x, y) {
var a;
a = x;
b = y;
return b + a;
return b + x;
}
}
}
@@ -3978,3 +3976,21 @@ cascade_switch: {
}
}
}
cascade_call: {
options = {
collapse_vars: true,
unused: true,
}
input: {
function f(a) {
var b;
return x((b = a, y(b)));
}
}
expect: {
function f(a) {
return x(y(a));
}
}
}