Repository navigation
Stop special-casing ZWNJ and ZWJ in the regexp identity escape tests - #5161
Merged
Merged
Conversation
gibson042
reviewed
Nov 4, 2026
Comment on lines
13
to
23
Member
There was a problem hiding this comment.
Suggested change
| var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029)); | |
| if (LineTerminator === false) { |
Contributor
Author
|
Thanks, applied all four in 8c7e30e. With Elimination gone, the 11 syntax characters it used to skip are now checked too, and both tests still pass on Node and engine262 and in the no-Annex-B model from the description. |
gibson042
approved these changes
Nov 6, 2026
Unicode 15.1 added U+200C and U+200D to ID_Continue, and ecma262 dropped their special case in tc39/ecma262#3074. Without Annex B, a backslash followed by either one is now an early error in a non-u RegExp literal, like any other ID_Continue code unit. These two tests still required both to parse, so they failed on such an engine. Only $ remains an IdentifierPart that is not ID_Continue.
Drop the Elimination list, since the code unit is always backslash escaped, and explain when a SyntaxError is acceptable. Co-authored-by: Richard Gibson <1199584+gibson042@users.noreply.github.com>
gibson042
force-pushed
the
zwnj-zwj-id-continue
branch
from
November 6, 2026 15:28
8c7e30e to
1de958b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5160.
Unicode 15.1 added U+200C and U+200D to ID_Continue, and tc39/ecma262#3074 removed their special case from the spec. In a non-u RegExp literal without Annex B, a backslash followed by an ID_Continue code unit is an early error, so a backslash followed by ZWNJ is now a SyntaxError, just like
/\a/.S7.8.5_A1.4_T2.jsandS7.8.5_A2.4_T2.jsaccept a SyntaxError only when the code unit is in ID_Continue, and they still listed ZWNJ and ZWJ next to$as exceptions that must parse. This PR leaves$as the only exception, since it is still an IdentifierPart that is not ID_Continue.The tests now pass whichever Unicode version an engine uses: ZWNJ may parse (before 15.1) or throw (15.1 and later).
Every engine in CI implements the Annex B IdentityEscape grammar and never throws here, so none of them shows the failure. To check the change, I ran both tests under a wrapper around
evalthat rejects a backslash followed by any ID_Continue code unit, the way an engine without Annex B would. The current tests fail at U+200C and the new ones pass. They also pass when ZWNJ and ZWJ are treated as pre-15.1 (not ID_Continue). And they still fail when the wrapper also wrongly rejects\$. Lint is clean, and both tests pass on Node and engine262.LLM disclosure: Claude Opus 5.5 helped me write and check this change; I reviewed the result.