tree-sitter-cpp icon indicating copy to clipboard operation
tree-sitter-cpp copied to clipboard

Template friend class of a one-to-many relationship was incorrectly parsed

Open nothankyouzzz opened this issue 4 years ago • 0 comments

Source code:

template <typename T> class A {};

class B {
  template <typename T> friend class A;
};

nvim-treesitter info:

template_declaration [0, 0] - [0, 33]
  parameters: template_parameter_list [0, 9] - [0, 21]
    type_parameter_declaration [0, 10] - [0, 20]
      type_identifier [0, 19] - [0, 20]
  class_specifier [0, 22] - [0, 32]
    name: type_identifier [0, 28] - [0, 29]
    body: field_declaration_list [0, 30] - [0, 32]
class_specifier [2, 0] - [4, 1]
  name: type_identifier [2, 6] - [2, 7]
  body: field_declaration_list [2, 8] - [4, 1]
    template_declaration [3, 2] - [3, 39]
      parameters: template_parameter_list [3, 11] - [3, 23]
        type_parameter_declaration [3, 12] - [3, 22]
          type_identifier [3, 21] - [3, 22]
      declaration [3, 24] - [3, 39]
        type: type_identifier [3, 24] - [3, 30]
        declarator: identifier [3, 31] - [3, 36]
        ERROR [3, 37] - [3, 38]
          identifier [3, 37] - [3, 38]

parse_error

As you can see, the template <typename T> friend class A; was regonized to a template declaration instand of friend declaration. This is clearly wrong.

nothankyouzzz avatar Jul 24 '21 02:07 nothankyouzzz