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

bug: wrong await_expression node when call_expression has a type_arguments #282

Open
2 tasks done
ofseed opened this issue Mar 4, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@ofseed
Copy link

ofseed commented Mar 4, 2024

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-typescript

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

No response

Describe the bug

When wrote a code snippet like this:

await f()

The tree will be

(program ; [0, 0] - [1, 0]
  (expression_statement ; [0, 0] - [0, 9]
    (await_expression ; [0, 0] - [0, 9]
      (call_expression ; [0, 6] - [0, 9]
        function: (identifier) ; [0, 6] - [0, 7]
        arguments: (arguments))))) ; [0, 7] - [0, 9]

But if the function f receives a type argument, like this

await f<T>()

The tree will be:

(program ; [0, 0] - [1, 0]
  (expression_statement ; [0, 0] - [0, 12]
    (call_expression ; [0, 0] - [0, 12]
      function: (await_expression ; [0, 0] - [0, 7]
        (identifier)) ; [0, 6] - [0, 7]
      type_arguments: (type_arguments ; [0, 7] - [0, 10]
        (type_identifier)) ; [0, 8] - [0, 9]
      arguments: (arguments)))) ; [0, 10] - [0, 12]

The location of the node await_expression will be in a different place in this case.

Steps To Reproduce/Bad Parse Tree

  1. Code snippet
await f<T>()
  1. The tree
(program ; [0, 0] - [1, 0]
  (expression_statement ; [0, 0] - [0, 12]
    (call_expression ; [0, 0] - [0, 12]
      function: (await_expression ; [0, 0] - [0, 7]
        (identifier)) ; [0, 6] - [0, 7]
      type_arguments: (type_arguments ; [0, 7] - [0, 10]
        (type_identifier)) ; [0, 8] - [0, 9]
      arguments: (arguments)))) ; [0, 10] - [0, 12]

Expected Behavior/Parse Tree

(program
  (expression_statement
    (await_expression
      (call_expression
        function: (identifier)
        type_arguments: (type_arguments
          (type_identifier))
        arguments: (arguments)))))

Repro

await f<T>()
@ofseed ofseed added the bug label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant