Skip to content

bug: supertypes (e.g. _declaration_statement) not queryable #292

@haxtibal

Description

@haxtibal

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-rust

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.25.8

Describe the bug

Since 2168ab9, tree-sitter-rust declares some supertypes. From my understanding of query syntax docs, we should now be able to write a simple query like (_declaration_statement) which will then match any sub-types, like enum_item or function_item.

However that doesn't work from me. I tried with nvim EditQuery and with python bindings Query(). In both cases I get an error "Invalid node type "_declaration_statement". How is this meant to work?

Just close if it's not a bug. I'm only learning about this and may have misunderstandings.

Steps To Reproduce/Bad Parse Tree

  1. Install tree-sitter-rust as .config/nvim/parser/rust.so
  2. Write a file test.rs in nvim, open query editor with :EditQuery
  3. enter (function_item) - no error
  4. enter (_declaration_statement) - Invalid node type "_declaration_statement"

Expected Behavior/Parse Tree

Query is accepted and works as described in query syntax docs.

Repro

// (_declaration_statement) should match for sub type function_item
fn foo() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions