improve collapse_vars (#2591)
- handle single-use assignments other than `AST_VarDef` - scan `AST_Call` for candidates
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user