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: Consecutive conditions using less-than "<" operator parsed as an ERROR #277

Open
2 tasks done
stefanus-nanami opened this issue Jul 18, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@stefanus-nanami
Copy link

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.22.6

Describe the bug

Consecutive conditions using operator < will produce ERROR. Using only one condition using operator < parsed without any ERROR.

Steps To Reproduce/Bad Parse Tree

Debug graph included below.

(ERROR [0, 0] - [11, 0]
  (struct_specifier [0, 0] - [3, 1]
    name: (type_identifier [0, 7] - [0, 8])
    body: (field_declaration_list [0, 9] - [3, 1]
      (field_declaration [1, 1] - [1, 12]
        type: (primitive_type [1, 1] - [1, 4])
        declarator: (field_identifier [1, 5] - [1, 11]))
      (field_declaration [2, 1] - [2, 12]
        type: (primitive_type [2, 1] - [2, 4])
        declarator: (field_identifier [2, 5] - [2, 11]))))
  type: (primitive_type [5, 0] - [5, 3])
  (function_declarator [5, 4] - [5, 21]
    declarator: (identifier [5, 4] - [5, 9])
    parameters: (parameter_list [5, 9] - [5, 21]
      (parameter_declaration [5, 10] - [5, 20]
        (type_qualifier [5, 10] - [5, 15])
        type: (type_identifier [5, 16] - [5, 17])
        declarator: (reference_declarator [5, 17] - [5, 20]
          (identifier [5, 19] - [5, 20])))))
  (identifier [7, 4] - [7, 5])
  (identifier [7, 6] - [7, 12])
  (number_literal [7, 15] - [7, 16])
  (identifier [7, 20] - [7, 21])
  (identifier [7, 22] - [7, 28])
  (ERROR [7, 31] - [8, 8]
    (number_literal [7, 31] - [7, 32]))
  (number_literal [8, 9] - [8, 11]))

Debug graph: log.zip

Expected Behavior/Parse Tree

Operator < should not produce any ERROR node.

Repro

struct X {
  int field0;
  int field1;
};

int func(const X& a)
{
  if(a.field0 < 0 || a.field1 < 0)
    return -1;
  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant