tree-sitter / tree-sitter/tree-sitter-cpp
bug: "=" parameter to pass-through macro leads to parenthesis being ignored
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 453
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
Description
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-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);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the parse of the provided DECLARE_VAR example in tree-sitter-cpp and compare it with the expected behavior. Trace how the pass-through macro argument containing "=" is parsed, then verify that the closing parenthesis and following statement are no longer absorbed into an optional parameter declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100