You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: this is not a bug in the library, but rather a bug in the Noir implementation. It can be reproduced with the following snippet:
use dep::fraction::{Fraction, MAX, floor, toFraction, addFraction};
fn main() {
let g1 = toFraction(true, 33333333, 5);
let g2 = toFraction(true, 500000, 33333333);
let a = addFraction(g1, g2);
print("a: ");
println(a);
let f1 = floor(a);
let f2 = MAX;
// assert(compareFraction(floor(a), MAX) == 2);
print("1 signs: ");
print(f1.sign);
print(" ");
println(f2.sign);
let _ = if (f1.sign != f2.sign) {
if (f1.sign) { 1 } else { 2 }
} else {
print("2 signs: ");
print(f1.sign);
print(" ");
println(f2.sign);
0
};
}
Note that in this code, "1 signs" and "2 signs" should print the same thing, because f1.sign and f2.sign are not modified in between. The output of nargo execute, however, is this:
# Description
## Problem\*
Resolves#5202
## Summary\*
The linked issue was coming from our if condition optimization where we
assume the value of an if's condition to be true within the then branch
and false within the else branch. It seems the `map_value` calls from
this weren't being reset properly since the nested `if f1.sign { .. } {
.. }`'s else branch assumed `f1.sign` to be false, which was not reset
properly after the `if`. I've temporarily disabled the optimization
until we can add it back without breaking this test.
## Additional Context
## Documentation\*
Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.
# PR Checklist\*
- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Aim
Debug a failing test in a third_party library (resurgencelabs/fraction).
Expected Behavior
Test is failing due to a bug in the library.
Bug
Test is failing due to a bug in the Noir language tools.
To Reproduce
Test "test_add_large()" fails with the following message:
compareFraction returns 1 instead of 2.
Note: this is not a bug in the library, but rather a bug in the Noir implementation. It can be reproduced with the following snippet:
Note that in this code, "1 signs" and "2 signs" should print the same thing, because f1.sign and f2.sign are not modified in between. The output of
nargo execute
, however, is this:Also note: using
nargo debug
results in the correct expected behavior:Project Impact
Blocker
Impact Context
This is a serious issue that undermines the credibility of using Noir in mission-critical systems and projects.
Workaround
None
Workaround Description
No response
Additional Context
This was discovered while trying to compile a collection of working programs and libraries written in Noir.
Installation Method
Compiled from source
Nargo Version
nargo version = 0.30.0 noirc version = 0.30.0+af57471035e4fa7eaffa71693219df6d029dbcde
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: