Skip to content
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

Unsigned integers do not overflow when they are defined as constants #3395

Closed
Savio-Sou opened this issue Nov 1, 2023 · 1 comment · Fixed by #3420
Closed

Unsigned integers do not overflow when they are defined as constants #3395

Savio-Sou opened this issue Nov 1, 2023 · 1 comment · Fixed by #3420
Assignees
Labels
bug Something isn't working

Comments

@Savio-Sou
Copy link
Collaborator

Savio-Sou commented Nov 1, 2023

Aim

Define constant unsigned integers, and summing them beyond their type boundaries.

Expected Behavior

E.g. given u8's boundary goes from 0 to 255, both of the following examples should fail:

  1. Adding u8 inputs together to beyond the type boundary:
fn main(x : u8, y : u8) {
    x + y;
}

with

x = "255"
y = "255"
  1. Adding u8 constants together to beyond the type boundary:
fn main() {
    let x : u8 = 255;
    let y : u8 = 255;
    x + y;
}

Bug

Proving (1) fails with Assertion failed: 'attempt to add with overflow' as expected.

Proving (2) however did not result in any errors.

Installation Method

Binary

Nargo Version

(Nightly)

nargo version = 0.18.0 noirc version = 0.18.0+a0985412594c5cbd35551afc7e94cb444723adb0 (git version hash: a098541, is dirty: false)

Additional Context

Discovered while drafting examples in #3393.

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@Savio-Sou Savio-Sou added the bug Something isn't working label Nov 1, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Nov 1, 2023
@Savio-Sou
Copy link
Collaborator Author

Assigning P-LOW under the assumption that this is a minor bug that does not affect a lot of users.

Please vote with emojis if your project is affected by this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants