tree-sitter / tree-sitter-c-sharp

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

Generic type in declaration parsed as binary expression #243

Closed Sjord closed 1 year ago

Sjord commented 1 year ago
IEnumerable<Clz> a = new Clz[1];

Expected:

(compilation_unit [0, 0] - [0, 32]
  (global_statement [0, 0] - [0, 32]
    (local_declaration_statement [0, 0] - [0, 32]
      (variable_declaration [0, 0] - [0, 31]
        type: (generic_name [0, 0] - [0, 16]
          (identifier [0, 0] - [0, 11])
          (type_argument_list [0, 11] - [0, 16]
            (predefined_type [0, 12] - [0, 15])))
        (variable_declarator [0, 17] - [0, 31]
          (identifier [0, 17] - [0, 18])
          (equals_value_clause [0, 19] - [0, 31]
            (array_creation_expression [0, 21] - [0, 31]
              (array_type [0, 25] - [0, 31]
                type: (predefined_type [0, 25] - [0, 28])
                rank: (array_rank_specifier [0, 28] - [0, 31]
                  (integer_literal [0, 29] - [0, 30]))))))))))

Actual:

(compilation_unit [0, 0] - [0, 32]
  (global_statement [0, 0] - [0, 32]
    (expression_statement [0, 0] - [0, 32]
      (assignment_expression [0, 0] - [0, 31]
        left: (binary_expression [0, 0] - [0, 18]
          left: (binary_expression [0, 0] - [0, 15]
            left: (identifier [0, 0] - [0, 11])
            right: (identifier [0, 12] - [0, 15]))
          right: (identifier [0, 17] - [0, 18]))
        (assignment_operator [0, 19] - [0, 20])
        right: (array_creation_expression [0, 21] - [0, 31]
          (array_type [0, 25] - [0, 31]
            type: (identifier [0, 25] - [0, 28])
            rank: (array_rank_specifier [0, 28] - [0, 31]
              (integer_literal [0, 29] - [0, 30]))))))))