Skip to content

fix: array size evaluation with modulo operator #930

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

makcandrov
Copy link
Contributor

The following code:

alloy_sol_types::sol! {
    struct Struc {
        uint256[11 % 8] arr;
    }
}

let _ = Struc {
    arr: [Default::default(); 11 % 8],
};

did not compile with the following error:

error[E0308]: mismatched types
 --> src\main.rs:9:10
  |
9 |     arr: [Default::default(); 11 % 8],
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an array with a size of 1, found one with a size of 3
  |
  = note: expected array `[alloy_sol_types::private::Uint<256, 4>; 1]`
             found array `[alloy_sol_types::private::Uint<256, 4>; 3]`

@github-project-automation github-project-automation bot moved this to Reviewed in Alloy Apr 17, 2025
@mattsse mattsse enabled auto-merge (squash) April 17, 2025 12:01
@mattsse mattsse merged commit 1445200 into alloy-rs:main Apr 17, 2025
30 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants