- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 70
 
Open
Description
Invalid Node Type Error with returns in Query
Issue Description
I am encountering an issue when querying method_declaration nodes using Tree-sitter. Specifically, using the field returns in my query causes an Invalid Node Type error, while replacing it with type resolves the issue.
Query Example Causing the Error
(class_declaration
  name: (identifier)
  body: (declaration_list
    (method_declaration
      (modifier)
      returns: (predefined_type)
      name: (identifier)
      parameters: (parameter_list
        (parameter
          type: (predefined_type)
          name: (identifier)))
      body: (block
        (return_statement
          (identifier))))))Expected Behavior
The query should retrieve all method_declaration nodes with their attributes, including the returns field for the return type.
File Context
I am using the example provided in the test/corpus/type-methods.txt with the following structure:
(compilation_unit
  (class_declaration
    name: (identifier)
    body: (declaration_list
      (method_declaration
        (modifier)
        returns: (predefined_type)
        name: (identifier)
        parameters: (parameter_list
          (parameter
            type: (predefined_type)
            name: (identifier)))))
Problem
The grammar for method_declaration nodes in the provided file references returns for the return type of the method. However, when querying with returns, Tree-sitter raises an error about an invalid node type. Replacing it with type works, but it seems inconsistent with the provided grammar definition.
Metadata
Metadata
Assignees
Labels
No labels