Open
Description
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.