-
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
@const creeping #1497
Comments
@kzc I'm more than happy to deprecate |
Should remove support for It will be treated like any other comment - just ignored and produce suboptimal code. Documentation should be updated to advise the use of the However, uglify ought to raise a fatal error in this case upon the illegal reassignment:
|
Node.js (and I supposed web browsers) would do this for us:
So would this not fall under the category of garbage in, garbage out? |
Works for me. |
I think we discounted raising an error upon Using either v2.7.5 or 2.8.0 staging #1485:
Yes, both are invalid programs, but Uglify is inconsistent between variable redeclaration and reassignment. Are we certain that no transform will incorrectly remove one of the reassignments thus emitting a "valid" program? |
Oh woah that is surprising, and I don't like surprises. Let me investigate the why and the how before getting back to you on that one. |
... ah, my eyes failed me. Okay those aren't as bad as I thought they are. Back in #1448 (comment) master
#1485
So #1450 optimised away the assignment which becomes problematic. |
The more I think about this, the more I'm tempted to eliminate this special case |
Enabling
But then again How difficult is it to just raise an error upon reassigning or redeclaring a The other issue with enabling |
The heuristic for trapping bad |
|
But commenting out that line will emit garbage-in/garbage-out code where the error has to be trapped by the JS engine. We should have uglify raise a fatal error at that point and exit. It's ill-formed JS. |
By not trapping the problem early we're putting a burden on all the optimizations to check for this ridiculous case. |
I thought |
Yeah, you have a point. It's a runtime error anyway, not a parse error:
|
At the very least uglify ought to warn that a |
Maybe uglify could offer a |
I can do a check for |
I thought |
Not if |
That does not help in the default compress case. Unless you wish to enable |
If you do decide to make such a change to enable |
@avdg @mishoo @rvanvelzen any objections to turning |
The problem with using warnings for |
No opinion on my part |
@kzc what other things can you think of |
That's the only |
- fix corner cases in `const` optimisation - deprecate `/*@const*/` fixes mishoo#1497
- fix corner cases in `const` optimisation - deprecate `/*@const*/` fixes mishoo#1497
See #1448 (comment) onwards
The text was updated successfully, but these errors were encountered: