New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of a trait method inside of another trait impl results in resolver errors #4943
Comments
Is the Looks like there's a lot of missing code from this snippet in general since |
Ah apologies, there's a full program below. I was trying to draw attention to the impls using each other but, yeah, it's confusing atm. Edit: ah, even that's missing the snippet. |
I've updated the main post. Looks like the |
I recreated this as: use dep::std::convert::From;
use dep::std::field;
struct MyU128 {
lo: Field,
hi: Field,
}
impl MyU128 {
fn from_u64s_le(_a: u64, _b: u64) -> Self {
Self {
lo: _a as Field, hi: _b as Field,
}
}
}
impl From<u64> for MyU128 {
fn from(value: u64) -> MyU128 {
MyU128::from_u64s_le(value, 0)
}
}
impl From<u32> for MyU128 {
fn from(value: u32) -> MyU128 {
MyU128::from(value as u64)
}
}
// impl Foo for MyU128 {
// fn foo(self, other: u8) -> MyU128 {
// MyU128::from(other)
// }
// }
fn main(mut x: u64) {
let mut small_int = MyU128::from(x);
assert(small_int.lo == x as Field);
assert(MyU128::from(3).lo == 3);
} and am getting the relevant |
Ah, I remember why this is happening. If there are multiple generic impls implemented on the same type we add neither to the type namespace currently since it'd lead to a name conflict between one |
Aim
I would like to use trait methods inside the impls of other traits for one of my structs.
Expected Behavior
This usage of traits implemented on a type in other trait impls for that type should be valid Noir.
Bug
The example program doesn't compile
instead we get the error messages
Commenting out the latter 2 trait impls removes all compilation errors (including the errors which occur inside the
main
function)To Reproduce
Project Impact
Nice-to-have
Impact Context
Nice to have as we can often pull the implementation out of the trait being called and then delegate to that.
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
Compiled from source
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: