tree-sitter-cpp
tree-sitter-cpp copied to clipboard
out-of-line "= default" constructor decl is parsed as an expression.
Testcase:
A::A() = default;
This is an ambiguous case (expression vs the constructor decl) -- from the log, tree-sitter actually parsed both, but in the final stage it chose the expression one (the precedence is the same, so the easier is being chosen).
One fix is to boost the precedence of the "default" in default_method_clause
, the following change seems working:
- default_method_clause: $ => seq('=', 'default', ';'),
+ default_method_clause: $ => seq('=', prec.dynamic(1, 'default'), ';'),
Can you re-test this with the latest commit? I can't reproduce it myself. It's parsed as a function definition with a default method clause for me.
yeah can't reproduce as well on master