noir
noir copied to clipboard
Using large `Field`'s in numeric generics fails with "array length too large"
Aim
Attempted to use a Field
larger than u32::MAX
as a numeric generic:
global A: Field = 4294967297;
fn foo<let A: Field>() { }
fn main() {
let C = foo::<A>();
}
Expected Behavior
Expected the program to compile successfully or fail with a clear error
Bug
Compilation fails with a message that the Field
is too large to be an array length, but it's not used as an array length:
❯ ~/.nargo/bin/nargo compile
warning: unused variable C
┌─ src/main.nr:12:9
│
12 │ let C = foo::<A>();
│ - unused variable
│
error: Integer too large to be evaluated to an array-length
┌─ src/main.nr:7:19
│
7 │ global A: Field = 4294967297;
│ ---------- Array-lengths may be a maximum size of usize::MAX, including intermediate calculations
│
Aborting due to 1 previous error
To Reproduce
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
nargo version = 0.34.0 noirc version = 0.34.0+5598059576c6cbc72474aff4b18bc5e4bb9f08e1 (git version hash: 5598059576c6cbc72474aff4b18bc5e4bb9f08e1, is dirty: false)
NoirJS Version
No response
Proving Backend Tooling & Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response