tree-sitter-cpp icon indicating copy to clipboard operation
tree-sitter-cpp copied to clipboard

out-of-line "= default" constructor decl is parsed as an expression.

Open hokein opened this issue 3 years ago • 1 comments

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'), ';'),

hokein avatar Mar 08 '21 08:03 hokein

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.

jdrouhard avatar Sep 26 '21 21:09 jdrouhard

yeah can't reproduce as well on master

amaanq avatar Jul 25 '23 10:07 amaanq