Skip to content

bug: Macro prefix to local variable creation leads to "missing semicolon" #300

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

Open
2 tasks done
BrickBee opened this issue Dec 10, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@BrickBee
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)

Playground (0.23.4?)

Describe the bug

Using the macro SET_ALIGN(16) as prefix instead of the direct struct alignas(16) leads to a "missing semicolon" error.

Steps To Reproduce/Bad Parse Tree

translation_unit [0, 0] - [1, 0]
  expression_statement [0, 0] - [0, 13]
    call_expression [0, 0] - [0, 13]
      function: identifier [0, 0] - [0, 9]
      arguments: argument_list [0, 9] - [0, 13]
        number_literal [0, 10] - [0, 12]
    MISSING ; [0, 13] - [0, 13]
  declaration [0, 14] - [0, 27]
    type: type_identifier [0, 14] - [0, 17]
    declarator: init_declarator [0, 18] - [0, 26]
      declarator: identifier [0, 18] - [0, 21]
      value: initializer_list [0, 24] - [0, 26]

Expected Behavior/Parse Tree

This might be difficult to handle, as the macro could be a regular function call that just happened to have no newline after it and is indeed missing a semicolon. A heuristic based on the missing line-break would work but be rather hacky. The parser recovers from this though.

Repro

SET_ALIGN(16) Foo bar = {};
@BrickBee BrickBee added the bug label Dec 10, 2024
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