Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Can't parse binary_expression containing 0 #283

Closed
2 tasks done
vanessa-rodrigues opened this issue Aug 23, 2024 · 0 comments · Fixed by #286
Closed
2 tasks done

bug: Can't parse binary_expression containing 0 #283

vanessa-rodrigues opened this issue Aug 23, 2024 · 0 comments · Fixed by #286
Labels

Comments

@vanessa-rodrigues
Copy link

vanessa-rodrigues commented Aug 23, 2024

Did you check existing issues?

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

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

tree-sitter 0.20.8

Describe the bug

Parsing a binary_expression containg a 0 inside a class is leading to a parsing error. The conflict seems to be related with the code introduced in this commit.
This might be related to bug 282

class A
{
	int variable = 0 + 1;
};

Example output:

(translation_unit [0, 0] - [4, 0]
  (class_specifier [0, 0] - [3, 1]
    name: (type_identifier [0, 6] - [0, 7])
    body: (field_declaration_list [1, 0] - [3, 1]
      (field_declaration [2, 1] - [2, 22]
        type: (primitive_type [2, 1] - [2, 4])
        declarator: (field_identifier [2, 5] - [2, 13])
        (ERROR [2, 16] - [2, 17])
        default_value: (unary_expression [2, 18] - [2, 21]
          argument: (number_literal [2, 20] - [2, 21]))))))

Steps To Reproduce/Bad Parse Tree

tree-sitter parse file.cpp

Expected Behavior/Parse Tree

(translation_unit [0, 0] - [4, 0]
  (class_specifier [0, 0] - [3, 1]
    name: (type_identifier [0, 6] - [0, 7])
    body: (field_declaration_list [1, 0] - [3, 1]
      (field_declaration [2, 1] - [2, 22]
        type: (primitive_type [2, 1] - [2, 4])
        declarator: (field_identifier [2, 5] - [2, 13])
        default_value: (binary_expression [2, 16] - [2, 21]
          left: (number_literal [2, 16] - [2, 17])
          right: (number_literal [2, 20] - [2, 21]))))))

Repro

class A
{
    int variable = 0 + 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant