Skip to content

Improve escape sequence handling in private names#50856

Merged
DanielRosenwasser merged 7 commits intomainfrom
privateNamesWithEscapes
Sep 20, 2022
Merged

Improve escape sequence handling in private names#50856
DanielRosenwasser merged 7 commits intomainfrom
privateNamesWithEscapes

Conversation

@DanielRosenwasser
Copy link
Copy Markdown
Member

@DanielRosenwasser DanielRosenwasser commented Sep 20, 2022

This PR makes two changes:

  1. It fixes how the parser acquires the name of a PrivateIdentifier from the scanner, preferring the "cooked" tokenValue after processing escape sequences rather than just reading the plain source (the "token text"). Previously, two private names with the same effective/cooked names would not resolve to each other unless their source text was verbatim identical.
  2. It fixes the scanner, which previously didn't expect a that a hash/pound (#) could be followed by a backlash (\).

There is still a slight problem around the fact that under ES3 and ES5 (our defaults), we don't recognize extended escape sequences at all. Ideally we would improve this by gracefully parsing and issuing an error that we can't emit them or something. But what that means is that I'm not yet certain as to whether the language service issue discovered within test262 (under formatjs) in #50835 is actually fixed by this. That might need to be a follow-up.

Fixes #50851.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PrivateName does not permit escape characters

3 participants