Repository navigation
Conversation
Reset the accumulated minimum when collapsing an optional loop so repeated empty alternatives retain their zero minimum. Add reduction and multi-engine functional coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d76b2ba7-1921-4e29-b0b3-77ad73e9c582
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions |
This was referenced Oct 7, 2026
Closed
This branch has not been deployed
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.
.NET 9: https://mihubot.xyz/regex?pattern=%28%3F%3Aa%2B%7C%29%7B2%7D&version=9.0
.NET 10: https://mihubot.xyz/regex?pattern=%28%3F%3Aa%2B%7C%29%7B2%7D&version=10.0
Repeated empty alternatives such as
(?:a+|){2}incorrectly reject"a". When collapsing nested loops,ReduceLoopsskips updating its accumulated minimum for a zero-minimum child. A subsequent merge then incorrectly reduces the pattern toa{2,}instead ofa*.Reset the accumulated minimum to zero when crossing an optional loop. Maximum counts, overflow handling, and the guards determining whether loops can safely be combined remain unchanged. The correction applies to interpreted, compiled, source-generated, and nonbacktracking regexes through their shared optimizer.
The empty-alternation optimization in #118087 exposed this preexisting accumulator defect.
Resolves #135329
Note
This change and description were prepared with GitHub Copilot.