-
Notifications
You must be signed in to change notification settings - Fork 219
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
"Expected array index to be a known constant" within an if statement #1964
Comments
Would modifying it in the way below change the business logic of the program? for i in 0..ACCOUNT_MAX_PRIVATE_CALLS {
let target_address = self.flattened_targets[i];
if target_address != 0 {
let function_selector = self.flattened_selectors[i];
let args_hash = self.flattened_args_hashes[i];
let (_callStackItem, updated_context) = PrivateCallStackItem::call_with_packed_args(target_address, function_selector, args_hash, context);
context = updated_context;
}
} to for i in 0..ACCOUNT_MAX_PRIVATE_CALLS {
let target_address = self.flattened_targets[i];
let function_selector = self.flattened_selectors[i];
let args_hash = self.flattened_args_hashes[i];
if target_address != 0 {
let (_callStackItem, updated_context) = PrivateCallStackItem::call_with_packed_args(target_address, function_selector, args_hash, context);
context = updated_context;
}
} |
Thanks for the quick reply @kevaundray! Unfortunately that doesn't fix the issue, I'm still getting the same compiler error:
|
I'd guess the error may be related to the entire context being conditionally assigned to within each This should be fixed once the dynamic indexing PR is merged: #1969 |
Aim
In the Aztec Noir library we have an
entrypoint
module with a function for executing a set of requests. Each loop currently runs only once, sinceACCOUNT_MAX_PRIVATE_CALLS
andACCOUNT_MAX_PUBLIC_CALLS
are both 1.https://github.com/AztecProtocol/aztec-packages/blob/07032c47f642de5bbd4bb8a2e16230f7a86662af/yarn-project/noir-contracts/src/libs/noir-aztec/src/entrypoint.nr#L91-L111
When increasing them to two, the compiler starts failing with the following error:
I've tried unrolling the loops and setting the index for accessing the arrays as a constant, like the following, but the error persists:
However, removing the if statements eliminates the problem:
Expected Behavior
Code shown above should compile.
Bug
Full output of the error in the first snippet, with constants set to two:
Full output of the error in the unrolled version:
To Reproduce
No response
Installation Method
None
Nargo Version
nargo 0.8.0 (git version hash: ea80de5, is dirty: false)
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: