tree-sitter-cpp icon indicating copy to clipboard operation
tree-sitter-cpp copied to clipboard

bug: "=" parameter to pass-through macro leads to parenthesis being ignored

Open BrickBee opened this issue 1 year ago • 0 comments

Did you check existing issues?

  • [X] I have read all the tree-sitter docs if it relates to using the parser
  • [X] I have searched the existing issues of tree-sitter-cpp

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

No response

Describe the bug

When a "=" is passed as parameter to a pass-through macro then the closing parenthesis isn't parsed correctly.

Steps To Reproduce/Bad Parse Tree

translation_unit [0, 0] - [2, 0]
  ERROR [0, 0] - [1, 12]
    identifier [0, 0] - [0, 11]
    optional_parameter_declaration [0, 12] - [1, 11]
      type: primitive_type [0, 12] - [0, 16]
      declarator: identifier [0, 17] - [0, 20]
      ERROR [0, 22] - [0, 29]
        true [0, 24] - [0, 28]
      default_value: call_expression [1, 0] - [1, 11]
        function: identifier [1, 0] - [1, 6]
        arguments: argument_list [1, 6] - [1, 11]
          identifier [1, 7] - [1, 10]

Expected Behavior/Parse Tree

Without resolving the macro the parser cannot know what's about to happen. Yet it shouldn't be baited by the "=" to turn all the lines that follow it into an optional_parameter_declaration

Repro

DECLARE_VAR(bool foo =) true;
printf(foo);

BrickBee avatar Dec 10 '24 12:12 BrickBee