noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
878 stars 190 forks source link

called `Option::unwrap()` on a `None` value when trying to fetch Field.to_le_bits() #1820

Closed weiler1 closed 1 year ago

weiler1 commented 1 year ago

Aim

I was just trying to print the value of the length of the array so formed in the case of:

let xy = 3; let b = xy.to_le_bits(32); std::println(b.len());

Expected Behavior

The value of the length of array b should be printed upon commanding

noir prove p --show-output

Bug

The app crashed with the message:

The application panicked (crashed). Message: called Option::unwrap() on a None value Location: crates/noirc_frontend/src/monomorphization/mod.rs:729

This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/. If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml

To Reproduce

  1. Clone this repository
  2. In the main.nr, add the lines mentioned above
  3. set x and y in Prover.toml to 4 and 9, respectively
  4. nargo check
  5. nargo prove p --show-output

Installation Method

Binary

Nargo Version

0.6.0

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

kevaundray commented 1 year ago

@Ethan-000 can you check to see if this is still an issue with the new experimental ssa?

Ethan-000 commented 1 year ago

@Ethan-000 can you check to see if this is still an issue with the new experimental ssa?

seems not

use dep::std;

fn main() {
    let xy = 3;
    let b = xy.to_le_bits(32);
    std::println(b.len());
}

this program returns

The application panicked (crashed).
Message:  called `Option::unwrap()` on a `None` value
Location: crates/noirc_frontend/src/monomorphization/mod.rs:837

with nargo execute and

 "0x0100"
Circuit witness successfully solved

with nargo execute --experimental-ssa

kevaundray commented 1 year ago

Thanks for checking -- closing this issue. Feel free to re-open if the problem persists