disable do{...}while(false) optimisation (#1534)

- fails to handle `break` in body

fixes #1532
This commit is contained in:
Alex Lam S.L
2017-03-03 00:54:41 +08:00
committed by GitHub
parent ee3b39b909
commit b49e142a26
2 changed files with 26 additions and 2 deletions

View File

@@ -2132,7 +2132,7 @@ merge(Compressor.prototype, {
} }
} else { } else {
// self instanceof AST_Do // self instanceof AST_Do
return self.body; return self;
} }
} }
if (self instanceof AST_While) { if (self instanceof AST_While) {

View File

@@ -213,6 +213,30 @@ evaluate: {
a(); a();
for(;;) for(;;)
c(); c();
d(); // rule disabled due to issue_1532
do d(); while (false);
}
}
issue_1532: {
options = {
evaluate: true,
loops: true,
}
input: {
function f(x, y) {
do {
if (x) break;
foo();
} while (false);
}
}
expect: {
function f(x, y) {
do {
if (x) break;
foo();
} while (false);
}
} }
} }