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: First-line inner attribute item is regarded as shebang #204

Closed
2 tasks done
monaqa opened this issue Nov 19, 2023 · 2 comments
Closed
2 tasks done

bug: First-line inner attribute item is regarded as shebang #204

monaqa opened this issue Nov 19, 2023 · 2 comments
Labels

Comments

@monaqa
Copy link

monaqa commented Nov 19, 2023

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-rust

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

tree-sitter 0.20.8

Describe the bug

If the first (non-blank / non-comment) line starts with #!, even if it should be parsed as an inner_attribute_item, it is regarded as a shebang.

Steps To Reproduce/Bad Parse Tree

(source_file [0, 0] - [3, 0]
  (shebang [0, 0] - [0, 27])
  (function_item [2, 0] - [2, 12]
    name: (identifier [2, 3] - [2, 7])
    parameters: (parameters [2, 7] - [2, 9])
    body: (block [2, 10] - [2, 12])))

Expected Behavior/Parse Tree

(source_file [0, 0] - [3, 0]
  (inner_attribute_item [0, 0] - [0, 27]
    (attribute [0, 3] - [0, 26]
      (identifier [0, 3] - [0, 8])
      arguments: (token_tree [0, 8] - [0, 26]
        (identifier [0, 9] - [0, 25]))))
  (function_item [2, 0] - [2, 12]
    name: (identifier [2, 3] - [2, 7])
    parameters: (parameters [2, 7] - [2, 9])
    body: (block [2, 10] - [2, 12])))

Repro

#![allow(unused_variables)]

fn main() {}
@monaqa monaqa added the bug label Nov 19, 2023
@amaanq
Copy link
Member

amaanq commented Nov 19, 2023

Thanks, fixed on master

@amaanq amaanq closed this as completed Nov 19, 2023
@monaqa
Copy link
Author

monaqa commented Nov 19, 2023

Thanks for the quick fix!

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

2 participants