-
Notifications
You must be signed in to change notification settings - Fork 200
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
for loop unused variable message error #1754
Comments
I spoke with @signorecello on discord I think if his handle is Zpedro |
I haven't looked into the unused variable warning yet (you can convert it to a warning with struct SignedMessage {
public_key: [u8; 128],
signature: [u8; 65],
hashed_message: [u8],
} You declare a field of a slice type, but this type does not work when used outside of function inputs since a slice type struct SignedMessage<N> {
public_key: [u8; 128],
signature: [u8; 65],
hashed_message: [u8; N],
} It's possible this may have been causing other issues in your code as well. Sorry for the confusing bug here. It is a known issue but something that I wish was clearer when using this syntax. I'll also add this is something we're looking at fixing by adding true slice types to Noir that don't desugar into array types. See PR #1728 |
I should have looked at this closer originally. So when you run the original program, nargo gives an error and a warning:
The first parse error is more important here. It isn't the most helpful, but it's a result of Noir not supporting the range operator Slices are eventually coming to Noir but aren't here quite yet unfortunately. For now if you want this code to work you'll likely need a helper function: fn split<T>(array: [T; 128]) -> ([T; 64], [T; 64]) {
let mut first_half = dep::std::unsafe::zeroed();
for i in 0 .. 64 {
first_half[i] = array[i];
}
let mut second_half = dep::std::unsafe::zeroed();
for i in 64 .. 128 {
second_half[i] = array[i];
}
(first_half, second_half)
} Apologies for the late answer! I'm going to close this since the original bug is related to slices which we already have tracking issues for (namely #1889 which is preventing us from enabling slices for users currently). |
Aim
I would like to be able to use for loops in noir
Expected Behavior
It should execute the for loop without error
Bug
I would like to verify signatures in a group and this is the function that I have
When trying to do this I get a misfiring of an error
To Reproduce
3.??
Installation Method
Binary
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: