tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: Parser errors when macros are invoked with multiple arguments

ribru17 opened this issue · comments

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)

No response

Describe the bug

When giving a macro multiple arguments (e.g. println!("{}", "hello");), the parser errors with something like:

(expression_statement)
 (unit_expression)
  (ERROR)

Perhaps similar to #98

This is especially unfortunate when the inside of the macro contains a function call, as it will not be recognized as a function call and thus not selectable by a textobjects query.

Steps To Reproduce/Bad Parse Tree

(expression_statement) 
 (macro_invocation) 
  macro: (identifier) 
  (token_tree) 
   (expression_statement) 
    (unit_expression) 
     (ERROR) 
   (string_literal) 
   (identifier) 
   (token_tree) 

Expected Behavior/Parse Tree

(expression_statement) 
 (macro_invocation) 
  macro: (identifier) 
  (token_tree) 
   (string_literal) 
   (call_expression) 
    function: (identifier) 
    arguments: (arguments) 

Repro

println!("{}", returns_string_hello());

That's not the output from tree-sitter's CLI (hint: you're using neovim with injections inside macro invocations)

I see, my apologies. Thanks for the information