tree-sitter-c
tree-sitter-c copied to clipboard
bug: using typeof in declarations leads to error nodes
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-c
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
0.23.1
Describe the bug
When using typeof inside parameter declaration it leads to error nodes
Steps To Reproduce/Bad Parse Tree
declaration [0, 0] - [0, 41] type_qualifier [0, 0] - [0, 5] type: type_identifier [0, 6] - [0, 12] declarator: parenthesized_declarator [0, 12] - [0, 38] parenthesized_declarator [0, 14] - [0, 29] parenthesized_declarator [0, 15] - [0, 27] identifier [0, 16] - [0, 22] ERROR [0, 23] - [0, 26] identifier [0, 23] - [0, 24] ERROR [0, 27] - [0, 28] number_literal [0, 27] - [0, 28] ERROR [0, 29] - [0, 36] identifier [0, 31] - [0, 36] ERROR [0, 39] - [0, 40]
Expected Behavior/Parse Tree
The below code is compilable but leads to misparsing with error nodes in treesitter.
Repro
struct X{
int _head;
};
int main()
{
const typeof( ((struct X *)0)->_head ) x;
}