You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to modify Serialize trait in noir-protocol-circuits in aztec-packages such that only 1 trait implementation is allowed. This led me to stumble upon this panic.
Expected Behavior
No panic
Bug
When a Noir trait implementation is ill-defined it causes Noir to panic.
Tagging @jfecher as we've discussed this on Slack.
To Reproduce
Compile the following code:
struct MockStruct {
value: Field,
}
pub trait Serialize {
let N: u32;
fn serialize(self) -> [Field; N];
}
impl Serialize for MockStruct {
let N = 1;
fn serialize(self) -> [Field; Self::N] {
[self.value]
}
}
pub struct Counted<T> {
pub inner: T,
pub counter: u32,
}
impl<T> Counted<T> {
pub fn new(inner: T, counter: u32) -> Self {
Self { inner, counter }
}
}
impl<T> Serialize for Counted<T> where T: Serialize {
type N = <T as Serialize>::N + 1;
fn serialize(self) -> [Field; Self::N] {
array_concat(self.inner.serialize(), [self.counter as Field])
}
}
// impl<T, let NT: u32> Serialize for Counted<T>
// where T: Serialize<N = NT>
// {
// let N = NT + 1;
// fn serialize(self) -> [Field; NT + 1] {
// array_concat(self.inner.serialize(), [self.counter as Field])
// }
// }
pub fn array_concat<T, let N: u32, let M: u32>(array1: [T; N], array2: [T; M]) -> [T; N + M] {
let mut result = [array1[0]; N + M];
for i in 1..N {
result[i] = array1[i];
}
for i in 0..M {
result[i + N] = array2[i];
}
result
}
You should get the following panic:
Nargo Version
nargo version = 1.0.0-beta.1 noirc version = 1.0.0-beta.1+74f0a50ed44e5712 (git version hash: 74f0a50ed44e5712, is dirty: false)
The text was updated successfully, but these errors were encountered:
Aim
I was trying to modify Serialize trait in
noir-protocol-circuits
inaztec-packages
such that only 1 trait implementation is allowed. This led me to stumble upon this panic.Expected Behavior
No panic
Bug
When a Noir trait implementation is ill-defined it causes Noir to panic.
Tagging @jfecher as we've discussed this on Slack.
To Reproduce
Compile the following code:
You should get the following panic:
Nargo Version
nargo version = 1.0.0-beta.1 noirc version = 1.0.0-beta.1+74f0a50ed44e5712 (git version hash: 74f0a50ed44e5712, is dirty: false)
The text was updated successfully, but these errors were encountered: