Skip to content
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

fix(lib): #2869 restrict pattern_map optimization #3440

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

quentinLeDilavrec
Copy link

Fixing #2869 by restricting pattern_map optimization in ts_query_new().

pattern_map is used to efficiently spawn query states given the current node symbol.
As an additional optimization, it also handles patterns with a wildcard root given that the first child is not a wildcard itself.
But for a pattern with a wildcard root, it is actually unsound to select a second step which is immediate,
because it will not be checked during the matching process here.

Moreover, it would be difficult to solve the unsoundness in advance(), and restricting the optimization should be a good enough trade-off.

fixing tree-sitter#2869 by restricting pattern_map optimization in ts_query_new()
i.e. do not select a second step which is immediate
@ObserverOfTime
Copy link
Member

Could you add a test?

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.

None yet

2 participants
-