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

Incorrect range of u128 #2623

Closed
Jurarpereurs opened this issue Sep 10, 2023 · 0 comments · Fixed by #2778
Closed

Incorrect range of u128 #2623

Jurarpereurs opened this issue Sep 10, 2023 · 0 comments · Fixed by #2778
Assignees
Labels
bug Something isn't working

Comments

@Jurarpereurs
Copy link

Aim

The range of u128 is incorrectly specified as 0..0.

To see that, try to compile the following code:

let x: u128 = 1;

The compiler would throw an error:

error: The literal `1` cannot fit into `u128` which has range `0..=0`

Expected Behavior

The compiler should not throw an error on the above code.

Bug

Create a project with nargo new range_bug, then save the following piece of code in to src/main.nr:

fn main() {
    let x: u128 = 1;
}

Then run nargo check and observe the following error:

warning: unused variable x
  ┌─ /home/Jurarpereurs/range_bug/src/main.nr:2:9
  │
2 │     let x: u128 = 1;
  │         - unused variable
  │

error: The literal `1` cannot fit into `u128` which has range `0..=0`
  ┌─ /home/Jurarpereurs/range_bug/src/main.nr:2:19
  │
2 │     let x: u128 = 1;
  │                   -
  │

Error: Aborting due to 1 previous error

Location:
    crates/nargo_cli/src/cli/mod.rs:91:5

To Reproduce

Run the following commands:

nargo new range_bug
cd range_bug
cat << EOF > src/main.nr
fn main() {
    let x: u128 = 1;
}
EOF
nargo check

Installation Method

Binary

Nargo Version

nargo 0.11.1 (git version hash: 39e1433, is dirty: false)

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

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
2 participants