Skip to content

bug: string_content inside raw_string_literal doesn't match leading whitespaces #251

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
1 of 2 tasks
Nosterx opened this issue Feb 13, 2025 · 0 comments
Open
1 of 2 tasks
Labels

Comments

@Nosterx
Copy link

Nosterx commented Feb 13, 2025

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.23.2

Describe the bug

whitespaces after r#" and before SELECT are not included in string_content

fn main() {
    let query = r#"
        SELECT * FROM users
    "#;
}

Steps To Reproduce/Bad Parse Tree

(source_file ; [0, 0] - [5, 0]
  (function_item ; [0, 0] - [4, 1]
    name: (identifier) ; [0, 3] - [0, 7]
    parameters: (parameters) ; [0, 7] - [0, 9]
    body: (block ; [0, 10] - [4, 1]
      (let_declaration ; [1, 4] - [3, 7]
        pattern: (identifier) ; [1, 8] - [1, 13]
        value: (raw_string_literal ; [1, 16] - [3, 6]
          (string_content ; [2, 8] - [3, 4]
            (program ; [2, 8] - [3, 4]
              (statement ; [2, 8] - [2, 27]
                (select ; [2, 8] - [2, 16]
                  (keyword_select) ; [2, 8] - [2, 14]
                  (select_expression ; [2, 15] - [2, 16]
                    (term ; [2, 15] - [2, 16]
                      value: (all_fields)))) ; [2, 15] - [2, 16]
                (from ; [2, 17] - [2, 27]
                  (keyword_from) ; [2, 17] - [2, 21]
                  (relation ; [2, 22] - [2, 27]
                    (object_reference ; [2, 22] - [2, 27]
                      name: (identifier)))))))))))) ; [2, 22] - [2, 27]

Expected Behavior/Parse Tree

(source_file ; [0, 0] - [5, 0]
  (function_item ; [0, 0] - [4, 1]
    name: (identifier) ; [0, 3] - [0, 7]
    parameters: (parameters) ; [0, 7] - [0, 9]
    body: (block ; [0, 10] - [4, 1]
      (let_declaration ; [1, 4] - [3, 7]
        pattern: (identifier) ; [1, 8] - [1, 13]
        value: (raw_string_literal ; [1, 16] - [3, 6]
          (string_content ; [1, 19] - [3, 4]
            (program ; [2, 8] - [3, 4]
              (statement ; [2, 8] - [2, 27]
                (select ; [2, 8] - [2, 16]
                  (keyword_select) ; [2, 8] - [2, 14]
                  (select_expression ; [2, 15] - [2, 16]
                    (term ; [2, 15] - [2, 16]
                      value: (all_fields)))) ; [2, 15] - [2, 16]
                (from ; [2, 17] - [2, 27]
                  (keyword_from) ; [2, 17] - [2, 21]
                  (relation ; [2, 22] - [2, 27]
                    (object_reference ; [2, 22] - [2, 27]
                      name: (identifier)))))))))))) ; [2, 22] - [2, 27]

different line is (string_content ; [1, 19] - [3, 4]

Repro

fn main() {
    let query = r#"
        SELECT * FROM users
    "#;
}
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