Fix sticky+global [Symbol.match] .NET fast path returning wrong results#2600
Merged
Conversation
The sticky branch compared match.Index (a string position) against a match counter and set the array length to the counter after writing index counter, so: - "aaa".match(/a/gy) returned ["a","a"] instead of ["a","a","a"] (off-by-one truncation), and - "ababab".match(/ab/gy) returned ["ab"] instead of ["ab","ab","ab"] (any match wider than one character broke the position/counter comparison). Track the expected continuation position (previous match end, +1 for empty matches per AdvanceStringIndex - this fast path is never unicode) and set the array length to the number of matches written. Regression tests cover adjacent multi-char matches, gap termination, empty-match advancement and lastIndex reset, each against both the .NET fast path and the generic exec loop. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lahma
enabled auto-merge (squash)
July 9, 2026 05:51
lahma
added a commit
that referenced
this pull request
Jul 9, 2026
Full re-run after the 2026-07 interpreter-parity campaign (#2600-#2606, #2608-#2611). Highlights vs the 2026-07-07 refresh: dromaeo-core-eval -40% (1.52 -> 0.92 ms, taking first place from NiL.JS), dromaeo-3d-cube -19% time / -35% allocation (7.38 -> 5.99 ms, moving ahead of NiL.JS - only the IL-compiling engine remains faster), stopwatch -7% (tied with the best interpreter, ahead of Jurassic), stopwatch-modern -13% (tied with Jurassic), object-array -10%, object-regexp -13%, object-string -5%. Competitor versions unchanged; their rows served as thermal canaries (all within a few percent of the previous refresh). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 13, 2026
This was referenced Jul 20, 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.
What
Fixes the sticky+global
[Symbol.match].NET fast path returning wrong results:Why
The sticky branch in
RegExpPrototype.Matchcomparedmatch.Index(a string position) against++li(a match counter), and calledSetLength(li)after having written array indexli:first match, and
How
The loop now tracks the expected continuation position — previous match end, or +1 for empty matches
(
AdvanceStringIndex; this fast path is guarded!fullUnicode, so the advance is always one UTF-16unit) — and sets the array length to the number of matches written.
lastIndexsemantics are alreadycovered by the
rx.Set(lastIndex, +0)at the top ofMatch(final observable value matches the spec'sfailing-exec reset).
Tests
Test262 doesn't cover sticky+global
[Symbol.match]through the .NET engine path, so this addsregression tests (each shape runs against both the .NET fast path and the generic exec loop via the
uflag):/a*/gy)lastIndexreset to 0 after the callGating
dotnet build Jint/Jint.csproj -c Release(all TFMs): ✅Jint.Testsnet10.0 + net472: ✅Jint.Tests.PublicInterfacenet10.0 + net472: ✅🤖 Generated with Claude Code