Repository navigation
regexp: allow up to 65535 capture groups - #625
Open
andreasrosdal wants to merge 1 commit into
Open
andreasrosdal wants to merge 1 commit into
andreasrosdal wants to merge 1 commit into
Conversation
Capture indices were stored on 8 bits, limiting a regexp to 255 capture groups. Store them on 16 bits in the save_start, save_end, save_reset and back reference opcodes and in the bytecode header.
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 #624.
libregexp.cstored capture indices on 8 bits, so a pattern with more than 255 capture groups failed withSyntaxError: too many captures. Bundlers emit such patterns (e.g. rspack's CSS chunk test is one large alternation of capture groups), so real applications fail to load.This widens the capture index to 16 bits and raises
CAPTURE_COUNT_MAXto 65535:save_start/save_endtake a 16-bit index,save_resettwo 16-bit indicesThe register count is unchanged. Since the regexp bytecode layout changes, previously serialized bytecode containing regexps is not compatible; I did not bump
BC_VERSION, tell me if you want that included.Tests added to
tests/test_builtin.js(300 groups with numbered and named back references, andsave_resetinside a quantifier).make testpasses, andlibregexp.cstill builds withDUMP_REOP.