improve collapse_vars on AST_Var (#1828)

Perform the same cascaded scanning within `var` statement as we do on array of statements.
This commit is contained in:
Alex Lam S.L
2017-04-19 04:49:09 +08:00
committed by GitHub
parent b4b9305db0
commit 4dcff038cb
2 changed files with 123 additions and 95 deletions

View File

@@ -1654,3 +1654,26 @@ iife_2: {
}(bar());
}
}
var_defs: {
options = {
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true
}
input: {
var f1 = function(x, y) {
var a, b, r = x + y, q = r * r, z = q - r, a = z, b = 7;
console.log(a + b);
};
f1("1", 0);
}
expect: {
var f1 = function(x, y) {
var r = x + y, a = r * r - r, b = 7;
console.log(a + b);
};
f1("1", 0);
}
expect_stdout: "97"
}