Skip to content
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

Where clause on generic trait's generic argument fails to resolve #6467

Open
michaeljklein opened this issue Nov 6, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@michaeljklein
Copy link
Contributor

michaeljklein commented Nov 6, 2024

Aim

Attempted to compile a program where a trait constrains one of its generic arguments:

trait Foo {
    fn foo(self) -> bool;
}

trait Bar<T> where T: Foo {}

impl<T, U> Bar<T> for U where T: Foo {}

pub fn bar<T, U>(x: T, _: U) -> bool where U: Bar<T> {
    x.foo()
}

fn main() {}

Note: this is blocking trait aliases of the form:

trait Qux<T> = Foo + Bar<T> where T: Baz;
//                          ^ this where clause results in the same "unresolved method call" error

Expected Behavior

Expected the x.foo() call to resolve since x: T and U: Bar<T> implies T: Foo

Bug

The method call does not resolve:

❯ ~/.nargo/bin/nargo compile
error: No method named 'foo' found for type 'T'
   ┌─ src/main.nr:10:510x.foo()
   │     -------
   │

Aborting due to 1 previous error

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

Note: need to update the docs that reference this issue

Project Impact

None

Blocker Context

No response

Nargo Version

nargo version = 0.37.0 noirc version = 0.37.0+fb1a8ca67c58d87991358078e6c532b49824fdb8 (git version hash: fb1a8ca, is dirty: false)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the bug Something isn't working label Nov 6, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Nov 6, 2024
@asterite
Copy link
Collaborator

asterite commented Nov 7, 2024

Expected the x.foo() call to resolve since x: T and U: Bar implies T: Foo

I'm not sure if this explicitness is expected from the language... Or, well, at least in Rust I get an error that says "the trait bound T: Foo is not satisfied, the trait Foo is not implemented for T" on Bar<T>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants