tree-sitter-cpp
tree-sitter-cpp copied to clipboard
bug: ifdef not supported inside constructor member initializer list
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)
Playground (0.23.4?)
Describe the bug
An #if / #ifdef / #endif is supported in different lists, but apparently not in the initializer list as it leads to an error. The parser seems to recover from the error though.
Steps To Reproduce/Bad Parse Tree
translation_unit [0, 0] - [7, 0]
function_definition [0, 0] - [6, 1]
declarator: function_declarator [0, 0] - [0, 10]
declarator: qualified_identifier [0, 0] - [0, 8]
scope: namespace_identifier [0, 0] - [0, 3]
name: identifier [0, 5] - [0, 8]
parameters: parameter_list [0, 8] - [0, 10]
field_initializer_list [1, 1] - [3, 13]
field_initializer [1, 3] - [1, 12]
field_identifier [1, 3] - [1, 6]
argument_list [1, 6] - [1, 12]
true [1, 7] - [1, 11]
ERROR [2, 0] - [2, 20]
identifier [2, 7] - [2, 20]
field_initializer [3, 3] - [3, 13]
field_identifier [3, 3] - [3, 6]
argument_list [3, 6] - [3, 13]
false [3, 7] - [3, 12]
ERROR [4, 0] - [4, 6]
body: compound_statement [5, 0] - [6, 1]
Expected Behavior/Parse Tree
The second field_initializer tree should be below a preproc_ifdef node and the two errors should not appear.
Repro
Bar::Bar()
: baz(true)
#ifdef TRIGGER_ERROR
, qux(false)
#endif
{
}