Skip to content

fix(query): prevent cross-branch capture contamination in alternations with quantifiers#5320

Merged
amaanq merged 1 commit intorelease-0.26from
backport-5317-to-release-0.26
Feb 10, 2026
Merged

fix(query): prevent cross-branch capture contamination in alternations with quantifiers#5320
amaanq merged 1 commit intorelease-0.26from
backport-5317-to-release-0.26

Conversation

@tree-sitter-ci-bot
Copy link

Description

Backport of #5317 to release-0.26.

…s with quantifiers

When a branch inside an alternation has a + or * quantifier, the
quantifier's pass_through step loops back to the branch's first step.
The alternation linking also sets that step's alternative_index to
point to the next branch. This causes the quantifier loop-back to
incorrectly explore other branches in the case of a failed match that
follows a successful match, contaminating captures.

This is corrected by redirecting the quantifier loop-back to a
"clean" copy of the target step without the alternative index pointing
to the next alternation branch.

Co-authored-by: Riley Bruins <ribru17@hotmail.com>
(cherry picked from commit 596a4d6)
@amaanq amaanq merged commit 89e804b into release-0.26 Feb 10, 2026
16 of 19 checks passed
@amaanq amaanq deleted the backport-5317-to-release-0.26 branch February 10, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants