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

- fails to handle `break` in body

fixes #1532
This commit is contained in:
alexlamsl 2017-03-03 00:02:12 +08:00
parent ee3b39b909
commit 93d6a0b534
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);
}
} }
} }