noir-lang / noir

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

feat!: always print Type::Constant kinds #6080

Closed michaeljklein closed 1 week ago

michaeljklein commented 1 week ago

Description

Problem*

Instead of printing:

Expected type [RootParityInput; 4)], found type [RootParityInput; 4)]

We print:

Expected type [RootParityInput; (4: u32)], found type [RootParityInput; (4: Field)]

Summary*

Additional Context

Documentation*

Check one:

PR Checklist*

github-actions[bot] commented 1 week ago

Changes to Brillig bytecode sizes

Generated at commit: e56f2c4cfb5c169a15358302d9d4dd0bf4cac948, compared to commit: 426f2955cbe4f086581d05eea7d06c47e0491195

There are no changes in circuit sizes

jfecher commented 1 week ago

For:

struct Foo<const N: usize> {
    x: [u8; N],
}

fn main() {}

fn bar<const M: u32>() -> Foo<M> {
    todo!()
}

Rust gives:

error: the constant `M` is not of type `usize`
 --> t.rs:8:27
  |
8 | fn bar<const M: u32>() -> Foo<M> {
  |                           ^^^^^^ expected `usize`, found `u32`
  |
note: required by a bound in `Foo`
 --> t.rs:2:12
  |
2 | struct Foo<const N: usize> {
  |            ^^^^^^^^^^^^^^ required by this bound in `Foo`
michaeljklein commented 1 week ago

The original issue appears to be resolved by https://github.com/noir-lang/noir/pull/6083