tree-sitter
tree-sitter copied to clipboard
Missing matches with some queries
Hi,
While debugging https://github.com/nvim-treesitter/nvim-treesitter/issues/963, we started to think the issue was not on our side, but on here.
The issue is fairly basic : when quering the tree, there is some times matches that aren't reported, while they actually exist.
At first we thought because it was because of some weird predicate issue on our side, but it is reproducible using tree-sitter-cli, so I am reporting that here.
Steps to reproduce
Using the two following files https://gist.github.com/vigoux/03b7a798cffeb8fc538b0fd8006b9abc
- Clone https://github.com/Azganoth/tree-sitter-lua
tree-sitter generatetree-sitter query query.scm test.luaa01does not appear, while it should
Additional notes
Its seems that the (return_statement) in the query is causing the issue, because removing it makes everything appear again.
After some investigation, and debugging, it seems that we are exceeding the match limit (the call to did_exceed_match_limit is returning 1).
This is a bug. The match limit should only be exceeded when a huge number of patterns overlap each other. There’s no overlapping at all. I’ll try to look into this when I get a chance.
Now that you say it is a bug, we get a strange SEGFAULT in approximately the same region, when using queries : https://github.com/neovim/neovim/issues/14369
Just as a note, I am running into this bug with https://github.com/tjdevries/tree-sitter-lua , which I use to parse & then generate vim help docs from lua files. Some files, since they have many functions, will not find all the matches, and therefore it drops them from the docs.
Happy to help debug anything else as well.
Any update on this problem ? Can we help in any way, or is there any ressource for contributing and attempt to fix this ?
Hello, Any update for this problem? I'm facing this issue with mostly "UT cpp files" where suddenly from a given point whole highlight is simple "white". Thank you for update.
I tried to reproduce what was described in the original post (using commit a943944e of the grammar mentioned), and the query output (truncated below) here seems to contain a01:
$ tree-sitter.master query query.scm test.lua
test.lua
pattern: 0
capture: scope, start: (3, 0), end: (5, 3)
capture: 0 - definition.associated, start: (3, 9), end: (3, 10), text: `m`
capture: 1 - definition.method, start: (3, 11), end: (3, 14), text: `a01`
capture: 3 - exported, start: (162, 7), end: (162, 8), text: `m`
(Might need to scroll to the right to see it.)
I used a tree-sitter cli built from c51896d32dcc11a38e41f36e3deb1a6a9c4f4b14.
May be I misunderstood some detail?
Hello, Any update for this problem? I'm facing this issue with mostly "UT cpp files" where suddenly from a given point whole highlight is simple "white". Thank you for update.
@BlueDrag0n Could you provide links to affected files?
Hmm, I can't reproduce this anymore w/ the lua example (I get a01), it might be fixed
I'm having issues with missing matches on the markdown parser: https://github.com/nvim-treesitter/nvim-treesitter-context/issues/289
With this tree:
With the query:
(section) @context
And I run this on the title2 section node. It does not match itself.
In Neovim you can test this with:
vim.treesitter.query.parse('markdown', '(section) @context'):iter_matches(vim.treesitter.get_node():parent():parent(), 0, 0, -1)()