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

String Literal Detection Issue When String Contains Keywords #11

Open
jconnor0426 opened this issue Aug 9, 2024 · 2 comments
Open

String Literal Detection Issue When String Contains Keywords #11

jconnor0426 opened this issue Aug 9, 2024 · 2 comments

Comments

@jconnor0426
Copy link

Hey all!

I found an issue using Treesitter python bindings with this PowerShell library.

Example PowerShell Script:

$groups = "ABC123"
if (-not ($groups -Contains "Domain Admins")) {
    exit
}

This results in a tree that has ERRORs around the the string "Domain Admins" as it trys to parse the in within Domain as if that was the keyword in.
Screenshot 2024-08-09 5 25 26 PM

@jconnor0426
Copy link
Author

The full tree output when running treesitter parse on the example script:

(program [0, 0] - [3, 1]
  (statement_list [0, 0] - [3, 1]
    (pipeline [0, 0] - [0, 18]
      (assignment_expression [0, 0] - [0, 18]
        (left_assignment_expression [0, 0] - [0, 7]
          (logical_expression [0, 0] - [0, 7]
            (bitwise_expression [0, 0] - [0, 7]
              (comparison_expression [0, 0] - [0, 7]
                (additive_expression [0, 0] - [0, 7]
                  (multiplicative_expression [0, 0] - [0, 7]
                    (format_expression [0, 0] - [0, 7]
                      (range_expression [0, 0] - [0, 7]
                        (array_literal_expression [0, 0] - [0, 7]
                          (unary_expression [0, 0] - [0, 7]
                            (variable [0, 0] - [0, 7])))))))))))
        (assignement_operator [0, 8] - [0, 9])
        value: (pipeline [0, 10] - [0, 18]
          (logical_expression [0, 10] - [0, 18]
            (bitwise_expression [0, 10] - [0, 18]
              (comparison_expression [0, 10] - [0, 18]
                (additive_expression [0, 10] - [0, 18]
                  (multiplicative_expression [0, 10] - [0, 18]
                    (format_expression [0, 10] - [0, 18]
                      (range_expression [0, 10] - [0, 18]
                        (array_literal_expression [0, 10] - [0, 18]
                          (unary_expression [0, 10] - [0, 18]
                            (string_literal [0, 10] - [0, 18]
                              (expandable_string_literal [0, 10] - [0, 18]))))))))))))))
    (if_statement [1, 0] - [3, 1]
      condition: (pipeline [1, 4] - [1, 44]
        (logical_expression [1, 4] - [1, 44]
          (bitwise_expression [1, 4] - [1, 44]
            (comparison_expression [1, 4] - [1, 44]
              (additive_expression [1, 4] - [1, 44]
                (multiplicative_expression [1, 4] - [1, 44]
                  (format_expression [1, 4] - [1, 44]
                    (range_expression [1, 4] - [1, 44]
                      (array_literal_expression [1, 4] - [1, 44]
                        (unary_expression [1, 4] - [1, 44]
                          (expression_with_unary_operator [1, 4] - [1, 44]
                            (unary_expression [1, 9] - [1, 44]
                              (parenthesized_expression [1, 9] - [1, 44]
                                (pipeline [1, 10] - [1, 17]
                                  (logical_expression [1, 10] - [1, 17]
                                    (bitwise_expression [1, 10] - [1, 17]
                                      (comparison_expression [1, 10] - [1, 17]
                                        (additive_expression [1, 10] - [1, 17]
                                          (multiplicative_expression [1, 10] - [1, 17]
                                            (format_expression [1, 10] - [1, 17]
                                              (range_expression [1, 10] - [1, 17]
                                                (array_literal_expression [1, 10] - [1, 17]
                                                  (unary_expression [1, 10] - [1, 17]
                                                    (variable [1, 10] - [1, 17])))))))))))
                                (ERROR [1, 18] - [1, 43]
                                  (simple_name [1, 19] - [1, 27])
                                  (ERROR [1, 29] - [1, 33])
                                  (ERROR [1, 35] - [1, 39])
                                  (ERROR [1, 41] - [1, 42])))))))))))))))
      (statement_block [1, 46] - [3, 1]
        statement_list: (statement_list [2, 4] - [2, 8]
          (flow_control_statement [2, 4] - [2, 8]))))))

@citronneur
Copy link
Member

Hello @jconnor0426
I was not able to reproduce your error with the last version of the parser. Could you please retry please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants