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

bug: ERROR on `typedef` with reference

Open quentin opened this issue 1 year ago • 1 comments

Did you check existing issues?

  • [X] I have read all the tree-sitter docs if it relates to using the parser
  • [X] I have searched the existing issues of tree-sitter-cpp

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

Parse of typedef declaration with a reference produces an ERROR node.

For instance in typedef int& t;

Steps To Reproduce/Bad Parse Tree

[translation_unit](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [1, 0]
  [type_definition](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [0, 15]
    type: [primitive_type](https://tree-sitter.github.io/tree-sitter/playground#) [0, 8] - [0, 11]
    [ERROR](https://tree-sitter.github.io/tree-sitter/playground#) [0, 11] - [0, 12]
    declarator: [type_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 13] - [0, 14]

Expected Behavior/Parse Tree

Expected some sort of reference node instead of ERROR.

Repro

// Example code that causes the issue
typedef int& t;

quentin avatar Feb 05 '24 15:02 quentin

I believe the original _type_declarator rule from tree-sitter-c needs to be extented with a reference type declarator.

quentin avatar Feb 05 '24 15:02 quentin