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

fix: properly capture Rust array expressions #610

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xzfc
Copy link

@xzfc xzfc commented Jan 30, 2025

Issue

Contents of Rust array_expressions is ignored. E.g. the following pattern:

language rust
`[foo, bar, baz]`

Matches every line of the following snippet:

[];
[a];
[a, b, c];

Cause

It seems that the cause is that the array_expression rule captures only the length field (e.g., 32 in [0u8; 32]), but not anything else.

{
"type": "array_expression",
"named": true,
"fields": {
"length": {
"multiple": false,
"required": false,
"types": [
{
"type": "_expression",
"named": true
}
]
}
},

Fix in this PR

This PR adds fields repeat (e.g., 0u8 in [0u8; 32]) and elements (e.g. a,b,c in [a,b,c]).
Related Rust reference page: https://doc.rust-lang.org/reference/expressions/array-expr.html

@xzfc xzfc requested a review from a team as a code owner January 30, 2025 13:26
Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you please add a test case too? https://github.com/getgrit/gritql/blob/main/crates/core/src/test.rs

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

Successfully merging this pull request may close these issues.

2 participants