Repository navigation
Conversation
The paren-based typescriptArrowFuncDef patterns repeat a single-character alternative, \%(\_[^()]\|(\_[^()]*)\)*. The backtracking engine pushes state for every iteration, so its memory grows with the length of the parameter list and can exceed 'maxmempattern' (E363). Unroll the loop as \_[^()]*\%((\_[^()]*)\_[^()]*\)* so each iteration consumes a whole parenthesized group. The matched text is unchanged. Backport of vim/vim PR 21423 by Doug Kearns (vim commit cff1d9e4e). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore the previous 'regexpengine' and 'maxmempattern' values instead of the defaults, so later cases keep the engine the suite was started with. Co-Authored-By: Claude Opus 5.5 <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.
This backports vim/vim PR 21423 by @dkearns (vim commit cff1d9e4e).
#306 removed the exponential backtracking in the paren-based
typescriptArrowFuncDefpatterns. Its single-character loop\%(\_[^()]\|(\_[^()]*)\)*, however, makes the backtracking engine (regexpengine=1) push state for every character. Memory grows with the length of the parameter list and can exceed'maxmempattern'(E363), as reported in vim/vim#17247.This PR unrolls the loop as
\_[^()]*\%((\_[^()]*)\_[^()]*\)*, so each iteration consumes a whole parenthesized group. Both thematchand theregion startpatterns are changed. The matched text is unchanged (still one level of nesting).Thanks to @dkearns for the fix and for agreeing to the backport (vim/vim#21423 (comment)).
Verification
synstack()names at every position between master and this branch, withregexpengine=1and2, ontest/test.ts(2245 positions),test/test.tsx(799) and the vim PR's test input (329). 0 differences.regexpengine=1 maxmempattern=1, master raises E363 at 129 of 329 positions in the vim PR's test input. This branch raises none.regexpengine=1 maxmempattern=1. With the CI command (Vader! syntax.vader tsx.vader, Vim 9.1 on macOS), this branch passes 151/151 and master exits with status 1. Not run locally with Neovim.merged/was regenerated withnode merge.js. Only the two lines changed in each file.🤖 Generated with Claude Code