-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add true
and false
as reserved words
#656
Conversation
Codecov Report
@@ Coverage Diff @@
## main #656 +/- ##
==========================================
- Coverage 82.65% 82.58% -0.08%
==========================================
Files 56 56
Lines 5928 5690 -238
Branches 1344 1344
==========================================
- Hits 4900 4699 -201
+ Misses 745 708 -37
Partials 283 283
Continue to review full report at Codecov.
|
Benchmark resultsBefore this PR: 283.7 thousand lines per second Measured change: 0.04% faster (2.04% slower to 4.49% faster) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the bug report and the fix! Agreed that this fixes the issue, and I just tested to confirm.
I was trying to figure out how I originally missed this case, and I see from MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar
this detail:
Additionally, the literals
null
,true
, andfalse
cannot be used as identifiers in ECMAScript.
So I guess those are not technically "keywords" but they're not allowed as identifiers either, so they should be in the list here.
There are a few more things that would be nice here:
- Add a test
- Add
null
as well - Document these three in a new section of the
RESERVED_WORDS
declaration - Maybe add a jsdoc comment for the
isIdentifier
function
But I'd be happy to do those as a quick follow-up PR.
Follow-up to #656: * Add `null` as a new case that should not have a variable declared in enum emit. * Rearrange the declaration to group these special non-identifier literals. * Add a test, also confirming that `undefined` is *not* reserved here. * Add a jsdoc comment for `isIdentifier`.
Follow-up to #656: * Add `null` as a new case that should not have a variable declared in enum emit. * Rearrange the declaration to group these special non-identifier literals. * Add a test, also confirming that `undefined` is *not* reserved here. * Add a jsdoc comment for `isIdentifier`.
Published as 3.20.3. |
Did not test it, but based on the discussion on #392 and #405 this should fix #655