compat_match: emit null for a non-participating group, not truncation - #16
Merged
Conversation
EigenScript v0.33.0 fixed the builtin regex_match (#629): a capture group that did not participate — an unmatched optional `(x)?`, or the losing side of an alternation — now emits null and the groups after it still arrive. Before, the first such group TERMINATED emission and the list was capped at 16. Our shim mirrored both bugs on purpose, so it was faithful to a builtin that has since been corrected, and the S8 differential (shim vs live builtin) went red the moment the runtime was right: `(a)|(b)` on "b" is `["b", null, "b"]` now, not `["b"]`. The shim's whole contract is to be drop-in for the builtin, so it follows. Drops the 16-element cap too — upstream now sizes the array from the compiled pattern, so a 17-group pattern returns 18 elements rather than silently 16. The documented invariant (group n at index n) only holds if a gap is a hole rather than a full stop. The S8 case that asserted truncation is retitled and re-pointed at the new shape rather than deleted — it is still the test that pins this behavior. Suite: ALL PASSED (359 checks + package smoke) against v0.33.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Lands with the compat_match fix in the same PR: the shim's new null-for- unset-group shape is only correct against the corrected builtin (#629), so on v0.32.0 the S8 differential would fail in the opposite direction. Fix and pin are one atomic step. Verified against the v0.33.0 runtime before the bump: tests/run.sh ALL PASSED (359 checks + package smoke). CLAUDE.md's two version-prose sites moved with the pin. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
EigenScript v0.33.0 fixed the builtin
regex_match(upstream #629): a capturegroup that did not participate — an unmatched optional
(x)?, or the losingside of an alternation — now emits null and the groups after it still arrive.
Previously the first such group terminated emission, and the list was capped
at 16 by a fixed
regmatch_t[16].Our
compat_matchshim mirrored both bugs deliberately (the S8 case wasliterally titled "shim match truncates at unset group"), which was the right
call while the builtin behaved that way and the wrong one the moment it
didn't. The S8 differential — shim vs live builtin over shared inputs — went
red as soon as the runtime was correct:
The shim's contract is to be drop-in for the builtin, so it follows. Also
drops the 16-element cap — upstream now sizes the array from the compiled
pattern, so a 17-group pattern returns 18 elements instead of silently 16. The
documented "group n sits at index n" invariant only holds if a gap is a hole
rather than a full stop.
The S8 check that asserted truncation is retitled and re-pointed at the new
shape rather than deleted; it is still the test that pins this behavior.
Verification
EIGENSCRIPT=eigenscript bash tests/run.shagainst EigenScript main @v0.33.0: ALL PASSED (359 checks + package smoke).
Found by the v0.33.0 pre-bump consumer sweep. The pin bump to v0.33.0 follows
separately.
🤖 Generated with Claude Code