Add error message for keywords with escapes in them#32718
Conversation
| 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.
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.
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.
@rbuckton checked jsc as well, which matches chrome's behavior - I've opened a bug there, too.
There was a problem hiding this comment.
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
|
@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