-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No overflow errors at compilation for add/sub constants operations. #4078
Comments
Note that this behaviour is by design such that tests will still produce We could restore this behaviour but would have to add an |
Also Rust doesn't error in this case: fn main() {
let x: u8 = 255 + 1;
} |
This is now tested in https://github.com/noir-lang/noir/blob/master/compiler/noirc_frontend/src/tests/bound_checks.rs and I just sanity-checked this specific case: ❯ ~/.nargo/bin/nargo compile
warning: unused variable var1
┌─ src/main.nr:3:9
│
3 │ let var1: u8 = 255 + 1;
│ ---- unused variable
│
warning: unused variable var2
┌─ src/main.nr:7:9
│
7 │ let var2: u8 = var + var;
│ ---- unused variable
│
warning: unused variable var3
┌─ src/main.nr:10:9
│
10 │ let var3: i64 = -18446744073709551616 - 1;
│ ---- unused variable
│
error: The value `-18446744073709551616` cannot fit into `i64` which has range `-9223372036854775808..=9223372036854775807`
┌─ src/main.nr:10:21
│
10 │ let var3: i64 = -18446744073709551616 - 1;
│ ---------------------
│
Aborting due to 1 previous error @TomAFrench will reopen if you think it needs a more specific regression test. |
Aim
We (https://github.com/FuzzingLabs) find that the compiler fails to raise overflow errors at compilation while adding/subtracting two constants together.
Expected Behavior
The documentation explicitly states that this particular error occurs during the creation of a proof of correct execution. However, it's important to note that Noir language closely resembles Rust, and in this case, such errors are raised during the compilation process.
Bug
nargo new test_issue
nargo compile
To Reproduce
No response
Installation Method
None
Nargo Version
No response
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: