Skip to content

bug: Doc-comments are not parsed correctly #236

Closed as not planned
Closed as not planned

Description

@nfejzic

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

The latest release (0.23) broke the parsing of doc-comments. Here's an example of how it looks like right now:

image

It should look like the following (as in release 0.21.2):

image

I don't know the specific commit that broke this. However, the issue is present from commit 7de6a3bc1ba213424c137f134d2872975b3b7fbe forwards.

I'm using neovim (v0.10.0) with nvim-treesitter plugin.

Here's the tree of the wrongly parsed part:

(source_file ; [0, 0] - [7, 0]
  (line_comment ; [0, 0] - [1, 0]
    outer: (outer_doc_comment_marker) ; [0, 2] - [0, 3]
    doc: (doc_comment)) ; [0, 3] - [1, 0]
  (function_item ; [1, 0] - [3, 1]
    name: (identifier) ; [1, 3] - [1, 7]
    parameters: (parameters) ; [1, 7] - [1, 9]
    body: (block ; [1, 10] - [3, 1]
      (line_comment ; [2, 4] - [3, 0]
        inner: (inner_doc_comment_marker) ; [2, 6] - [2, 7]
        doc: (doc_comment))))) ; [2, 7] - [3, 0]

Steps To Reproduce/Bad Parse Tree

  1. Open a Rust file.
  2. Find (or create) a doc comment
  3. The /// and //! symbols of doc comments are parsed wrong, with third character parsed as operator (I think?)

Expected Behavior/Parse Tree

The /// symbol should be parsed as one symbol.

Repro

/// This is a doc comment
fn main() {
    //! this is inside function comment
}

Activity

  1. mawkler commented on Sep 9, 2024

    @mawkler

    Came here since I'm having the same issue

  2. amaanq commented on Sep 9, 2024

    @amaanq
    Member

    Highlights are implementation-dependent and are not controlled here. The parse tree is correct, this is the parser repo.

  3. nfejzic commented on Sep 10, 2024

    @nfejzic
    Author

    @amaanq Thank you for the info 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions