extend inline (#2714)

- compress `function` with variables within loops
- restrict to `AST_Var` for better compatibility with ES6+
This commit is contained in:
Alex Lam S.L
2018-01-04 12:58:40 +08:00
committed by GitHub
parent c598a12af9
commit 9b58b54e2d
2 changed files with 40 additions and 25 deletions

View File

@@ -1299,6 +1299,7 @@ issue_2630_2: {
passes: 2,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
@@ -1905,6 +1906,7 @@ inline_true: {
use_before_init_in_loop: {
options = {
inline: true,
side_effects: true,
toplevel: true,
}
input: {
@@ -1918,9 +1920,9 @@ use_before_init_in_loop: {
}
expect: {
var a = "PASS";
for (var b = 2; --b >= 0;) (function() {
var c = (c && (a = "FAIL"), 1);
})();
for (var b = 2; --b >= 0;)
c = void 0, c = (c && (a = "FAIL"), 1);
var c;
console.log(a);
}
expect_stdout: "PASS"