Intrinsic::toRadix
handles constant and non-constant inputs differently
#2452
Labels
bug
Something isn't working
Aim
I'm wanting to get consistent behaviour between a
to_be_bytes
call made with constant inputs or with unknown inputs.Expected Behavior
The results of
x.to_be_bytes(31)
should return the same value whetherx
is known at compile time or not.Bug
If the
to_be_radix
call gets an constant input and is simplified then we add extra padding terms.noir/crates/noirc_evaluator/src/ssa/ir/instruction/call.rs
Lines 315 to 347 in 168e0db
This padding does not exist however if we are performing this
to_be_radix
call at runtime.noir/crates/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs
Lines 809 to 860 in 168e0db
This is an inconsistency which mean two calls with otherwise identical inputs to have different results.
To Reproduce
Compile the program below
The array length assertion will fail.
(I've been a bit roundabout with the equality checking as
assert(constant_byte_array == byte_array)
causes a panic)Installation Method
Compiled from source
Nargo Version
nargo 0.10.3 (git version hash: 168e0db, is dirty: true)
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: