noir-lang / noir

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

Trait with superfluous generic argument panics #5542

Closed michaeljklein closed 1 month ago

michaeljklein commented 1 month ago

Aim

Attempted to compile the following program:

impl std::ops::Add<()> for () {
    fn add(self, other: ()) -> () { }
}

fn main() { }

Expected Behavior

The program to compile successfully

Bug

Compilation panics with:

❯ nargo compile
The application panicked (crashed).
Message:  assertion `left == right` failed
  left: 0
 right: 1
Location: compiler/noirc_frontend/src/elaborator/mod.rs:1526

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

Binary (noirup default)

Nargo Version

nargo version = 0.31.0 noirc version = 0.31.0+45e82a672b9ba7f7326e8d9f8800e2489013e2e8 (git version hash: 45e82a672b9ba7f7326e8d9f8800e2489013e2e8, is dirty: false)

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

TomAFrench commented 1 month ago

Note this is because the Add trait is not generic.

https://github.com/noir-lang/noir/blob/5bbce7977f72b07336bc8ef09f6acff687f1644a/compiler/noirc_frontend/src/elaborator/mod.rs#L1527