tree-sitter
tree-sitter copied to clipboard
The last child anchor `.` in queries doesn't make any difference for a specific parser.
Problem
For the nushell parser.
The query is supposed to match only the last element in the code, but matches both.
- It fails for almost all node types of nushell
- It works for some other parsers like bash
Steps to reproduce
- clone the parser repo
tree-sitter generatetree-sitter query test.scm test.nu
test.scm:
(pipeline
(pipe_element) @foo .)
test.nu
foo
| bar
output
pattern: 0
capture: 0 - foo, start: (0, 0), end: (0, 3), text: `foo`
pattern: 0
capture: 0 - foo, start: (1, 2), end: (1, 5), text: `bar`
Expected behavior
Only match the last pipe_element, bar in test.nu above.
Tree-sitter version (tree-sitter --version)
0.25.4
Operating system/version
macOS 15.5
I'm running into the same issue with https://github.com/christoph-dfinity/tree-sitter-motoko
Notably I also work around the same whitespace issue the nu parser is in their grammar.