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

unreachable code: Failed to find trait impl during monomorphization #5017

Closed jfecher closed 2 months ago

jfecher commented 5 months ago

Aim

use dep::std::collections::map::HashMap;
use dep::std::hash::poseidon2::Poseidon2Hasher;
use dep::std::hash::BuildHasherDefault;

global MAP: HashMap<Field, Field, 2, Poseidon2Hasher> = {
    let mut map = HashMap::default();
    map.insert(1, 2);
    map.insert(3, 4);
    map
};

fn main() {
    println(MAP);
}

Expected Behavior

The compiler to error that there is no impl BuildHasher for Poseidon2Hasher. The correct type would be BuildHasherDefault<Poseidon2Hasher>

Bug

The application panicked (crashed).
Message:  internal error: entered unreachable code: Failed to find trait impl during monomorphization. The failed constraint(s) are:
  Poseidon2Hasher: BuildHasher<H'304 -> '22670>
Location: compiler/noirc_frontend/src/monomorphization/mod.rs:1060

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

asterite commented 2 months ago

@jfecher I think this got fixed in #5602. Or, put another way, #5029 was a duplicate of this one. But please reopen if what I'm saying is wrong.

jfecher commented 2 months ago

Looks like there's a new error here that the expression type is ambiguous when it should not be.

asterite commented 2 months ago

Should we reopen this issue or open a new one?

asterite commented 2 months ago

(the "No matching impl" is still there, I wonder if the new error happens as a cascade because of the other error)

jfecher commented 2 months ago

@asterite I made a replacement issue for it since it is a different error: https://github.com/noir-lang/noir/issues/5626