-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illegal break statement - Compress option removes do statements when while is false. do { ... } while(false) #1075
Comments
That's a good report. I don't have an immediate fix, but just to show you how I write similar code: OUT: {
if (some_condition) {
break OUT;
}
if (something_else) {
break OUT;
}
// ... etc.
} There's no need for the |
@volumeone Unable to reproduce.
Which uglify version and flags are you using? |
Thanks @kzc I was using the wrong NPM package: uglify-js2 which was at version 2.1.11. I installed uglify-js with version 2.6.2 and that's no longer an issue. |
Yeah, this issue is a plague :-) See #936 |
This still doesn't work on 2.8.4. Perhaps the same as newly opened #1532?
It works when setting evaluate to false in compress options. |
@christensson I think it's a new regression instead of an old bug - please follow/comment on #1532 instead. |
In a do-while statement, if while is always false, it will remove the do and while, but leave the code inside the block. That makes sense unless there are break statements left over.
For example: this is a technique to avoid deeply nested IF statements:
Uglify converts that to this:
which causes an "Illegal break statement" error.
The do-while statements should not be removed when they contain break statements.
The text was updated successfully, but these errors were encountered: