disable do{...}while(false) optimisation (#1534)
- fails to handle `break` in body fixes #1532
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user