noir-lang / noir

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

Panic when monomorphizing `HashMap` code #4663

Open jfecher opened 6 months ago

jfecher commented 6 months ago

Aim

use dep::std::collections::map::{ HashMap };
use dep::std::hash::BuildHasherDefault;
use dep::std::hash::pedersen::PedersenHasher;

fn main() {
    let map: HashMap<u64, u64, 10, BuildHasherDefault<PedersenHasher>> = HashMap::default();
    println(map == map);
}

Expected Behavior

The code to execute and print an empty hashmap.

Bug

The application panicked (crashed).
Message:  internal error: entered unreachable code: Failed to find trait impl during monomorphization. The failed constraint(s) are:
  BuildHasherDefault<PedersenHasher>: BuildHasher
Location: compiler/noirc_frontend/src/monomorphization/mod.rs:1022

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
exit 101

To Reproduce

1. 2. 3. 4.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

TomAFrench commented 5 months ago

New repo


use dep::std::collections::map::{ HashMap };
use dep::std::hash::BuildHasherDefault;
use dep::std::hash::poseidon::PoseidonHasher;

fn main() {
    let map: HashMap<u64, u64, 10, BuildHasherDefault<PoseidonHasher>> = HashMap::default();
    println(map == map);
}