noir icon indicating copy to clipboard operation
noir copied to clipboard

Fix `eval_global_as_array_length` to support non-array-length types

Open michaeljklein opened this issue 4 months ago • 0 comments

Aim

https://github.com/noir-lang/noir/pull/6137 adds the warning EvaluatedGlobalIsntU32 when eval_global_as_array_length is used on non-u32 types.

This is connected to the following (test: issue) pairs:

  • numeric_generic_field_larger_than_u32: https://github.com/noir-lang/noir/issues/6125
  • numeric_generic_field_arithmetic_larger_than_u32: https://github.com/noir-lang/noir/issues/6126

Expected Behavior

eval_global_as_array_length to either handle larger types, e.g. Field properly, or to only be used when the globals are within the expected range

TODO:

  • [ ] See how much overlap there between the evaluate global as array length function and the comptime interpreter code: (some of) the comptime interpreter method(s) may be usable here
  • [ ] Test that we error for overflowing in intermediate u32 kind computations, e.g. the equivalent of U32_MAX + 1 - X where X > 0

Bug

  • numeric_generic_field_larger_than_u32: https://github.com/noir-lang/noir/issues/6125
  • numeric_generic_field_arithmetic_larger_than_u32: https://github.com/noir-lang/noir/issues/6126

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

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

michaeljklein avatar Oct 08 '24 10:10 michaeljklein