Skip to content

Conversation

@zharinov
Copy link
Member

@zharinov zharinov commented Jan 3, 2026

Summary

Fixes the "search scope family of bugs" where the search loop operates below the level of alternation/backtracking semantics, causing cursor advancement to "consume" positions before other branches can try them.

  • Alternation branches now use exact navigation (Nav::to_exact()) - branches match at current position only
  • Definition bodies now use Nav::StayExact - named definitions match at cursor position, caller owns search

This ensures that when [(A) (B)] is matched where A = (function_call) and B = (juxt_function_call):

  1. Branch A tries at current position with exact nav
  2. If A fails, backtrack to try B at same position
  3. Only after all branches fail does the parent context advance

Previously, A's search loop could advance past positions that B should have tried.

Test plan

  • All 751 tests pass
  • Named definitions in alternation work: [(A) (B)] returns 2 matches
  • Full Gradle pattern works with tagged union output
  • Previous JavaScript alternation fix still works

@zharinov zharinov enabled auto-merge (squash) January 3, 2026 20:57
@zharinov zharinov merged commit 526279c into master Jan 3, 2026
4 checks passed
@zharinov zharinov deleted the fix/search-scope-ownership branch January 3, 2026 20:59
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