tree-sitter / tree-sitter/tree-sitter-cpp
bug: Consecutive conditions using less-than "<" operator parsed as an ERROR
Open
Nobody has claimed this yet.
bug
- 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)
tree-sitter 0.22.6
Describe the bug
Consecutive conditions using operator < will produce ERROR. Using only one condition using operator < parsed without any ERROR.
Steps To Reproduce/Bad Parse Tree
Debug graph included below.
(ERROR [0, 0] - [11, 0]
(struct_specifier [0, 0] - [3, 1]
name: (type_identifier [0, 7] - [0, 8])
body: (field_declaration_list [0, 9] - [3, 1]
(field_declaration [1, 1] - [1, 12]
type: (primitive_type [1, 1] - [1, 4])
declarator: (field_identifier [1, 5] - [1, 11]))
(field_declaration [2, 1] - [2, 12]
type: (primitive_type [2, 1] - [2, 4])
declarator: (field_identifier [2, 5] - [2, 11]))))
type: (primitive_type [5, 0] - [5, 3])
(function_declarator [5, 4] - [5, 21]
declarator: (identifier [5, 4] - [5, 9])
parameters: (parameter_list [5, 9] - [5, 21]
(parameter_declaration [5, 10] - [5, 20]
(type_qualifier [5, 10] - [5, 15])
type: (type_identifier [5, 16] - [5, 17])
declarator: (reference_declarator [5, 17] - [5, 20]
(identifier [5, 19] - [5, 20])))))
(identifier [7, 4] - [7, 5])
(identifier [7, 6] - [7, 12])
(number_literal [7, 15] - [7, 16])
(identifier [7, 20] - [7, 21])
(identifier [7, 22] - [7, 28])
(ERROR [7, 31] - [8, 8]
(number_literal [7, 31] - [7, 32]))
(number_literal [8, 9] - [8, 11]))
Debug graph: log.zip
Expected Behavior/Parse Tree
Operator < should not produce any ERROR node.
Repro
struct X {
int field0;
int field1;
};
int func(const X& a)
{
if(a.field0 < 0 || a.field1 < 0)
return -1;
return 0;
}
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 with the provided C++ reproduction and inspect its parse output using the tree-sitter CLI and the supplied debug graph. Compare the consecutive less-than conditions with a single condition; done means the reproduced input parses without any ERROR node.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100