-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow use of ES3 future reserved words in dot notation (regardless of option.es5) #674
Comments
Out of curiosity, where in the spec does it say that using future reserved words in dot notation is ok? |
i don't think it's called out explicitly somewhere in a way like "property names may be reserved words". from http://es5.github.com/#x7.6 you can see what is allowed for an IdentifierName ...and then from http://es5.github.com/#x11.1.5
you can see that a PropertyName can be an IdentifierName. putting all this together, property names can be reserved words. |
I see:
and
So Also |
right... but - so |
Well.. reserved words are always allowed in dot notation in ES5. No doubt there :) JSHint explicitly doesn't warn for it with The point here is about ES3. We know in ES3 reserved words were not allowed in dot notation. So something like So, pre-ES5 browsers don't seem to consider Future Reserved Words illegal in dot notation, only actual Reserved Words. Meaning, we don't have to emit an error when validating under ES3 when using Future Reserved Words in dot notation. Many people don't even know about Future Reserved Words (and as such just use them), and there was no reason to believe otherwise as apparently browsers didn't care either. |
sorry... i just assumed ES5. |
This commit makes JSHint properly recognize FutureReservedWords both for ES3 and ES5 environments. From now on, unless option es5 is set, JSHint will warn about all FutureReservedWord identifiers per ECMA-262 (Ed. 3). However, it won't warn about such identifiers in a property context: var throws = 1; // Warning a.throws = 1; // No warning For ES5 it now recognizes strict-mode specific FutureReservedWords: //jshint es5:true var let = 1; // No warning (function () { "use strict"; var let = 1; // Warning }()); I also made the parser a bit more tolerant towards FutureReservedWords in statement labels. So the code below will trigger warning but still be parsed completely (before it would exit with false positives): volatile: for (var i = 0; i < 10; i ++) { break volatile; } Closes jshintGH-674.
Words like
static
andthrows
are future reserved words since ES3. However the thing about future reserved words (contrary to reserved words) is that to my knowledge no browser anywhere disallowed use of them the way they disallowed reserved words.In the code I'm currently pluggin in it makes use of a prototype method called
throws
and property calledstatic
.I ran tests for this against a whole bunch of browsers and they all worked fine:
TestSwarm report: http://integration.wmflabs.org/testswarm/job/1
QUnit test runner: http://toolserver.org/~krinkle/tmp/test-js/?module=Prop%20static
And what engines will do in the future doesn't realy matter since from ES5 onwards using them in dot notation is allowed either way.
The text was updated successfully, but these errors were encountered: