Skip to content

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.
https://github.com/getgrit/gritql/blob/5af841f57592f287bdd736a87ec4008c77d88603/resources/node-types/rust-node-types.json#L522-L536

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
Collaborator

@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