tree-sitter / tree-sitter-c-sharp

C# Grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indexer with varargs fails to parse

Sjord opened this issue · comments

class A {
    public int this[params string[] arguments] {
        get { return 1; }
    }
}
(compilation_unit [0, 3] - [5, 0]
  (class_declaration [0, 3] - [4, 1]
    name: (identifier [0, 9] - [0, 10])
    body: (declaration_list [0, 11] - [4, 1]
      (indexer_declaration [1, 4] - [3, 5]
        (modifier [1, 4] - [1, 10])
        type: (predefined_type [1, 11] - [1, 14])
        parameters: (bracketed_parameter_list [1, 19] - [1, 46]
          (parameter [1, 20] - [1, 45]
            type: (array_type [1, 20] - [1, 35]
              type: (identifier [1, 20] - [1, 26])
              (ERROR [1, 27] - [1, 33]
                (identifier [1, 27] - [1, 33]))
              rank: (array_rank_specifier [1, 33] - [1, 35]))
            name: (identifier [1, 36] - [1, 45])))
        accessors: (accessor_list [1, 47] - [3, 5]
          (accessor_declaration [2, 8] - [2, 25]
            body: (block [2, 12] - [2, 25]
              (return_statement [2, 14] - [2, 23]
                (integer_literal [2, 21] - [2, 22])))))))))
Program.cs	0 ms	(ERROR [1, 27] - [1, 33])

params is handled by parameter_array, but that is not used in indexer_declaration.

image

Yeah this should be using _formal_parameter_list which takes care of the params version.

Additionally I think parameter_array should be hidden (prefixed with _) to better align with Roslyn.

I can put together a PR or can review one of yours.

Thanks!