tree-sitter / tree-sitter-c-sharp

C# Grammar for tree-sitter
MIT License
177 stars 47 forks source link

Fix "logical and" parsed as "cast + dereference" #294

Closed gonglinyuan closed 1 year ago

gonglinyuan commented 1 year ago

The expression (a) && b in this statement:

bool c = (a) && b;

was mistakenly parsed as a cast expression of type a applied to &&b, which is variable b dereferenced via & twice. However, it should have been parsed just as a logical_and expression.

This PR changed the grammar to fix this issue.

damieng commented 1 year ago

Thanks for the fix!

damieng commented 1 year ago

I'm going to have to revert this as it's causing the following regression:

Sprite mySprite = GetNode<Sprite>("Sprite");

Should be an invocation_expression on the right-hand side but this change is causing it to be an (incorrect) binary_expression now.

Not sure how we didn't have test coverage for this scenario.

gonglinyuan commented 1 year ago

I'm going to have to revert this as it's causing the following regression:

Sprite mySprite = GetNode<Sprite>("Sprite");

Should be an invocation_expression on the right-hand side but this change is causing it to be an (incorrect) binary_expression now.

Not sure how we didn't have test coverage for this scenario.

299 should fix this issue