Skip to content

The last child anchor . in queries doesn't make any difference for a specific parser. #4558

@blindFS

Description

@blindFS

Problem

For the nushell parser.

Image

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

  1. clone the parser repo
  2. tree-sitter generate
  3. tree-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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions