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: Incorrect parsing of doc comments #246

Open
2 tasks done
wetneb opened this issue Nov 14, 2024 · 0 comments
Open
2 tasks done

bug: Incorrect parsing of doc comments #246

wetneb opened this issue Nov 14, 2024 · 0 comments
Labels

Comments

@wetneb
Copy link

wetneb commented Nov 14, 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-rust

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

No response

Describe the bug

Similarly to #244, the parsing of doc comments (things that start with ///) is also incorrect.

Steps To Reproduce/Bad Parse Tree

Parse the example below, you get:

(source_file [0, 0] - [4, 0]
  (mod_item [0, 0] - [3, 1]
    name: (identifier [0, 4] - [0, 9])
    body: (declaration_list [0, 10] - [3, 1]
      (function_item [1, 4] - [1, 23]
        (visibility_modifier [1, 4] - [1, 7])
        name: (identifier [1, 11] - [1, 18])
        parameters: (parameters [1, 18] - [1, 20])
        body: (block [1, 21] - [1, 23]))
      (line_comment [2, 4] - [3, 0]
        outer: (outer_doc_comment_marker [2, 6] - [2, 7])
        doc: (doc_comment [2, 7] - [3, 0])))))

This should generate an error instead.

Expected Behavior/Parse Tree

The following example is accepted by the grammar, while it shouldn't

mod tests {
    pub fn execute() {}
    /// hello world
}

The following example fails to associate the doc comment to the function declaration:

mod tests {
    /// hello world
    pub fn execute() {}
}

Repro

Parse the examples above.
@wetneb wetneb added the bug label Nov 14, 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