This is a tracking issue to see the progress on validating which contextual keywords can be used as identifiers. All contextual keywords are listed below from https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/#contextual-keywords.
Tree sitter is performing context aware lexing, so some of the keywords can already be used as identifiers even without listing them in _contextual_keywords. Some of them need special handling, and some of them are never going to be correctly handled. Examples for the latter:
var in implicit_type could also be parsed as a named type.
nint, nuint in predefined_type could also be parsed as a named type.
notnull in type_parameter_constraint can be parsed as a notnull constraint or a type constraint.
- ...
In these cases we should choose the most likely option as the preferred parse rule.
Keywords:
This is a tracking issue to see the progress on validating which contextual keywords can be used as identifiers. All contextual keywords are listed below from https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/#contextual-keywords.
Tree sitter is performing context aware lexing, so some of the keywords can already be used as identifiers even without listing them in
_contextual_keywords. Some of them need special handling, and some of them are never going to be correctly handled. Examples for the latter:varinimplicit_typecould also be parsed as a named type.nint,nuintinpredefined_typecould also be parsed as a named type.notnullintype_parameter_constraintcan be parsed as anotnullconstraint or a type constraint.In these cases we should choose the most likely option as the preferred parse rule.
Keywords:
set,get,init,add,remove#279value.dynamicandnameoffrom contextual keywords #281fileidentifiers #277set,get,init,add,remove#279set,get,init,add,remove#279dynamicandnameoffrom contextual keywords #281nameofcontextual keyword test cases #290set,get,init,add,remove#279scopedas identifier name #275set,get,init,add,remove#279@keywordinsideinit/setaccessors.var#163varto contextual keywords #280