Skip to content

Allow contextual keywords to be used as identifiers #276

@tamasvajk

Description

@tamasvajk

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions