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] Matching string literals in Rust inner attributes behaves strangely #1060
Comments
This is already reported at #1057. |
Alright. I saw it, but didn't think it was exactly related. Sorry for the duplicate. |
Not a duplicate anymore? 😄 |
Sorry I misread you case by seeing string literal 🤣 |
OK, no problem 🙂 An idea what the problem might be, then? |
It is probably tree-sitter's issue. I will investigate it later |
tree-sitter/tree-sitter-rust#204 The issue is also fixed in new tree-sitter release. But unfortunately we are blocked now. |
Closing this in favor of #1104 |
Got it, thanks! |
Fixed in #1119 |
Can confirm it works under |
Hi!
⏯ Playground Link
Playground link with relevant code
💻 Code
Code:
Rule:
🙁 Actual behavior
The first attribute is matched, but not the second, although there is only a formatting difference between the two:
Weird element: if the inner attributes are switched, i.e. the one written on a single line is put on the first line, then the one on three lines is not matched anymore and only the third string is.
Also weird: if the inner attributes are turned to regular ones (
#[...]
), then there is no issue anymore.Still weird: I cannot make the Playground reproduce the issue, but I can only do so locally. See below for detailed version information.
All these behaviors can also be seen if the rule is "inverted" by removing the
not
. Same ifany: - kind: attribute_item - kind: inner_attribute_item
is used instead ofkind: attribute
.🙂 Expected behavior
Only the third string should be matched, whatever the formatting or relative order of inner attributes:
Meta
Ending note: this is the only real issue I encountered while developing a relatively-complex rule for a fairly-sized codebase. It might even be due to a tree-sitter bug. Overall, ast-grep actually works quite well! Thanks ❤️
The text was updated successfully, but these errors were encountered: