Open vezenovm opened 1 year ago
There are a number of other optimisations which we could turn off in order to improve debugging here, e.g. the redundant range optimisation can result in an overflow not being displayed due to the fact that it's being caught later.
An alternative approach is for tests to make the input be seen as non-constant, so that you can reproduce the exact environment one gets when a program is executed (with optimizations)
Linking this comment (https://github.com/noir-lang/noir/pull/2446#discussion_r1307701028) to note another optimization that can be removed in a debug compilation mode
In the short term (and complementary to debug mode in the future), we could add something similar to Rust's blackbox
function. This would just be an identity function which is listed as having side-effects, which would block any SSA optimizations from being applied to the outputs.
Problem
When working with
nargo test
, everything supplied to a function is a constant. This leads to issues as outlined in this PR: https://github.com/noir-lang/noir/pull/2116, whereprintln
does not work in tests with failing constraints. Essentially a failed constraint is resolved during compilation before we ever reach execution (where theprintln
foreign call is handled).Happy Case
We should offer a
debug
compile option that does not enforce constrain instructions at compile-time. This compile option will be enabled duringnargo test
to allowprintln
to execute even with compile time constraint failures.Alternatives Considered
Otherwise
println
just will not work during failing tests which leads to inconsistent functionality withnargo execute
. No realistic alternatives.Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response