-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add error message for keywords with escapes in them #32718
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 error message for keywords with escapes in them #32718
Conversation
break; | ||
case 10000: | ||
x /= x; | ||
default: // Error, third 'default' clause | ||
def\u0061ult: // Error, fourth 'default' clause. | ||
~~~~~~~~~~~~ | ||
!!! error TS1260: Keyword must not contain escaped characters |
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.
Yep, it is correct to issue an error here. You can paste const a = {def\u0061ult: 12}
into the repl and be greeted with an error. It surprised me, tbh.
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.
Fun fact: After some discussion with @rbuckton, while this errors in chrome (therefore v8), it does not in firefox and edge - per spec it doesn't seem like it should be an error, either (since anywhere an identifier is parse-able it should work). A crbug has been logged
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.
@rbuckton checked jsc as well, which matches chrome's behavior - I've opened a bug there, too.
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.
I dug through test262 but couldn't find a test for this case. The closest I could find was for a BindingIdentifier, not an IdentifierName:
- https://github.com/tc39/test262/blob/master/test/language/identifiers/val-default.js
- https://github.com/tc39/test262/blob/master/test/language/identifiers/val-default-via-escape-hex4.js (Unicode escapes in BindingIdentifier)
- https://github.com/tc39/test262/blob/master/test/language/reserved-words/ident-name-keyword-prop-name.js
tests/baselines/reference/switchStatementsWithMultipleDefaults.errors.txt
Show resolved
Hide resolved
@RyanCavanaugh wanna look over this again? |
@typescript-bot perf test this |
Heya @weswigham, I've started to run the perf test suite on this PR at d6ab219. You can monitor the build here. It should now contribute to this PR's status checks. |
@typescript-bot perf test this instead |
Heya @weswigham, I've started to run the perf test suite on this PR at 4657e04. You can monitor the build here. It should now contribute to this PR's status checks. Update: The results are in! |
@rbuckton done~ |
@weswigham Here they are:Comparison Report - master..32718
System
Hosts
Scenarios
|
Perf results are negligible - nice. |
Fixes #32700