Fix duplicate named capturing groups and clean up regex test262 exclusions#2320
Merged
Conversation
…sions (38 test262 tests) - Fix RegExpPrototype groups object construction for duplicate named capturing groups: pre-initialize all unique group names with undefined in source order, then only update when a capture actually matches. This prevents non-participating groups from overwriting successful captures. Applies to exec, match, matchAll, replace, and indices. - Remove regexp-lookbehind feature exclusion (most tests pass, only 2 individual files excluded for .NET-specific capture semantics) - Clean up regex exclusions: use glob for CharacterClassEscapes, remove duplicates, add proper categorization comments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lahma
enabled auto-merge (squash)
March 6, 2026 20:34
This was referenced Mar 7, 2026
This was referenced Jun 8, 2026
This was referenced Jun 29, 2026
This was referenced Jul 7, 2026
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.
Summary
RegExpPrototypegroups object construction for duplicate named capturing groups: pre-initialize all unique group names withundefinedin source order, then only update when a capture actually matches. This prevents non-participating groups from overwriting successful captures withundefined. Applies toexec,match,matchAll,replace, andindices.regexp-lookbehindfeature exclusion — most lookbehind tests already pass, only 2 individual files excluded for .NET-specific capture semantics in lookbehind backreferences.Net result: +38 passing test262 tests (92,410 → 92,448), 0 failures, no Acornima changes needed.
Duplicate named groups fix
The core issue: when building the
groupsobject for regex match results, iterating groups in order and callingCreateDataPropertyOrThrowfor each caused non-participating groups (from unmatched alternatives) to overwrite successful captures withundefined.Example:
/(?<x>a)|(?<x>b)/.exec("b")— group 1 ((?<x>a)) doesn't match, group 2 ((?<x>b)) matches"b". Previously, processing group 1 first would setgroups.x = undefined, then group 2 would setgroups.x = "b"— but only if usingCreateDataPropertyOrThrowwhich creates a new property each time. The fix uses a two-phase approach: first pre-initialize all unique names, then only update on successful captures.6 tests with quantified groups (
{2}) remain excluded due to .NET'sSystem.Text.RegularExpressionsretaining captures from previous iterations (JavaScript resets them).Test plan
🤖 Generated with Claude Code