tree-sitter / tree-sitter-c-sharp

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

Add `ref`/`ref readonly` types to the type system #251

Closed tamasvajk closed 1 year ago

tamasvajk commented 1 year ago

This PR partially covers https://github.com/tree-sitter/tree-sitter-c-sharp/issues/247.

Previously public ref readonly int M() was parsed with 3 modifiers on the method declaration, but this didn't match the semantics of the modifiers. Ref types are introduced in this PR, so the above method declaration parses with a single public modifier, and its return type is a ref_type.

I tried solving this issue with modifying the precedence of parameters vs types (and arguments vs ref_expressions), but that would require changing many other rule precedences. (I gave up on that approach). Instead, this PR removes ref from the general modifier list, and adjusts minimally the precedences.

tamasvajk commented 1 year ago

@damieng Do you usually do any larger scale testing for changes that might have a broad impact?

damieng commented 1 year ago

The CI does a full parse against NUnit, JSON.NET and Orchard repos albeit older versions that don't exercise a lot of the newer paths.

If there is a regression in the ability to parse those files it will cause a CI failure but we don't do anything with the parse tree itself to see what changed/improved.

The relevant scripts are in the scripts folder (you can run them yourself too) along with the known failures files - all three are combinations of #if where you would have to parse the whole block multiple times following each possible combination to adequately check which tree-sitter doesn't support.