Skip to content

Conversation

@aplefull
Copy link
Contributor

@aplefull aplefull commented Jan 7, 2026

Step 2.b of the RepeatMatcher states that once minimum repetitions are satisfied, empty matches should not be considered for further repetitions. This was not being enforced for quantifiers that allow 0 matches, like ?, so we had extra capture group matches.

Fixes #7332
Fixes #7117

Test 262:

    test/built-ins/RegExp/S15.10.2.8_A3_T17.js                 ❌ -> ✅
    test/built-ins/RegExp/lookahead-quantifier-match-groups.js ❌ -> ✅
    test/staging/sm/RegExp/exec.js                             ❌ -> ✅
    test/staging/sm/RegExp/sticky.js                           ❌ -> ✅

@aplefull aplefull requested a review from alimpfard as a code owner January 7, 2026 12:36
Copy link
Contributor

@alimpfard alimpfard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, not too sure if I love a FailIfEmpty op since we have Fail + JumpNonEmpty, but I don't see a reason to not have one so it's all good.

// CHECKPOINT _C
// REGEXP
// FAILIFEMPTY _C
// JUMP_NONEMPTY _C _START JUMP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can then be a jump.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change! Yeah, I also wasn't sure about the new op, but I've had multiple attempts at trying to do that cleanly without it and couldn't make it work nicely. Oh, and I forgot to rebaseline WPT...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, we have the opcode space, might as well use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, updated WPT expectations, should be good now

Step 2.b of the RepeatMatcher states that once minimum repetitions
are satisfied, empty matches should not be considered for further
repetitions. This was not being enforced for optional quantifiers
like `?`, so we had extra capture group matches.
@aplefull aplefull force-pushed the regex-clear-groups branch from 1865f55 to 66a2814 Compare January 7, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants