Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Node Type Error with returns in Query #358

Open
VishwasSomasekhariah opened this issue Nov 27, 2024 · 1 comment
Open

Invalid Node Type Error with returns in Query #358

VishwasSomasekhariah opened this issue Nov 27, 2024 · 1 comment

Comments

@VishwasSomasekhariah
Copy link

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.

@VishwasSomasekhariah
Copy link
Author

@amaanq Any insight you can give me would be greatly appreciated. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant