tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
357 stars 101 forks source link

bug: Parser errors when macros are invoked with multiple arguments #206

Closed ribru17 closed 11 months ago

ribru17 commented 11 months ago

Did you check existing issues?

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());
amaanq commented 11 months ago

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

ribru17 commented 11 months ago

I see, my apologies. Thanks for the information