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
The proving phase would complain that constraints are unsatisfiable when dividing an unsigned integer by zero:
let a:u8 = 3 / 0;
However, when changing the variable type to Field, the proving phase would not complain:
let a:Field = 3 / 0;
It would be better to make the behavior consistent. Also, the compiler should explicitly detect and give more informative error messages for divide-by-zero.
Expected Behavior
The compiler should explicitly issue an error message for divide-by-zero.
Bug
Please see steps to reproduce.
To Reproduce
Save the following code into src/main.nr:
use dep::std;fnmain(){let a:u8 = 3 / 0;
std::println(a);}
Run the following command:
nargo prove
You would see the following error message:
error: Unsatisfied constraint
┌─ /home/Jurarpereurs/src/main.nr:4:17
│
4 │ let a: u8 = 3 / 0;
│ ----- Constraint failed
Error: could not satisfy all constraints
Location:
crates/nargo_cli/src/cli/mod.rs:74:5
Then change the variable type to Field:
use dep::std;fnmain(){let a:Field = 3 / 0;
std::println(a);}
Run the following command:
nargo prove
The proving phase would succeed and you would see the following output:
"0x00"
Installation Method
Binary
Nargo Version
nargo 0.9.0 (git version hash: 35404ba, is dirty: false)
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:
jfecher
changed the title
Constraint failure in the case of divide-by-zero
Divide-by-zero is a constraint failure for integers but not for FieldAug 4, 2023
Aim
The proving phase would complain that constraints are unsatisfiable when dividing an unsigned integer by zero:
However, when changing the variable type to Field, the proving phase would not complain:
It would be better to make the behavior consistent. Also, the compiler should explicitly detect and give more informative error messages for divide-by-zero.
Expected Behavior
The compiler should explicitly issue an error message for divide-by-zero.
Bug
Please see steps to reproduce.
To Reproduce
Save the following code into
src/main.nr
:Run the following command:
You would see the following error message:
Then change the variable type to Field:
Run the following command:
The proving phase would succeed and you would see the following output:
"0x00"
Installation Method
Binary
Nargo Version
nargo 0.9.0 (git version hash: 35404ba, is dirty: false)
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: