tree-sitter icon indicating copy to clipboard operation
tree-sitter copied to clipboard

Missing matches with some queries

Open vigoux opened this issue 4 years ago • 5 comments

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

  1. Clone https://github.com/Azganoth/tree-sitter-lua
  2. tree-sitter generate
  3. tree-sitter query query.scm test.lua
  4. a01 does 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.

vigoux avatar Apr 14 '21 12:04 vigoux

After some investigation, and debugging, it seems that we are exceeding the match limit (the call to did_exceed_match_limit is returning 1).

vigoux avatar Apr 16 '21 15:04 vigoux

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.

maxbrunsfeld avatar Apr 16 '21 15:04 maxbrunsfeld

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

vigoux avatar Apr 17 '21 15:04 vigoux

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.

tjdevries avatar Apr 23 '21 12:04 tjdevries

Any update on this problem ? Can we help in any way, or is there any ressource for contributing and attempt to fix this ?

vigoux avatar Jul 07 '22 07:07 vigoux

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 avatar Mar 02 '23 10:03 BlueDrag0n

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?

sogaiu avatar Mar 02 '23 10:03 sogaiu

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?

ahlinc avatar Mar 02 '23 15:03 ahlinc

Hmm, I can't reproduce this anymore w/ the lua example (I get a01), it might be fixed

amaanq avatar Jul 31 '23 12:07 amaanq

I'm having issues with missing matches on the markdown parser: https://github.com/nvim-treesitter/nvim-treesitter-context/issues/289

With this tree:

image

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)()

lewis6991 avatar Aug 27 '23 13:08 lewis6991