Skip to content

fix: pattern_index parameter to generic predicates is incorrect #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2025

Conversation

davidt
Copy link
Contributor

@davidt davidt commented Jul 23, 2025

When a generic predicate callable is used, the documented signature indicates that the third argument should be the pattern index. Unfortunately, the value that was being passed was an index into an internal array of only the patterns containing predicates, not the true index of the pattern. This made it impossible for a custom directive to store information into the relevant pattern_settings dict (similar to how the built-in #set! directive does).

This change fixes that by storing the pattern index into the QueryPredicateGeneric structure, and then plumbing that through to the predicate callable.

When a generic predicate callable is used, the documented signature
indicates that the third argument should be the pattern index.
Unfortunately, the value that was being passed was an index into an
internal array of only the queries containing predicates, not the true
index of the pattern. This made it impossible for a custom directive to
store information into the relevant `pattern_settings` dict (similar to
how the built-in `#set!` directive does).

This change fixes that by storing the pattern index into the
`QueryPredicateGeneric` structure, and then plumbing that through to the
predicate callable.
@ObserverOfTime ObserverOfTime merged commit dd89ca6 into tree-sitter:master Jul 23, 2025
23 checks passed
@davidt davidt deleted the push-komnkmllmvuo branch July 23, 2025 15:30
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