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

Function where clauses with trait arguments fail #5186

Closed
michaeljklein opened this issue Jun 5, 2024 · 0 comments · Fixed by #5595
Closed

Function where clauses with trait arguments fail #5186

michaeljklein opened this issue Jun 5, 2024 · 0 comments · Fixed by #5595
Assignees
Labels
bug Something isn't working

Comments

@michaeljklein
Copy link
Contributor

Aim

Attempted to use a trait in a function with a where clause:

trait Foo<A> {
    fn foo(self, x: A) -> bool;
}

// This works:
// fn bar<T, U>(x: T, y: U) -> bool where T: Foo<U> {
//     x.foo(y)
// }

// This fails:
fn bar<T, U, V>(x: (T, U), y: V) -> bool where (T, U): Foo<V> {
    x.foo(y)
}

Expected Behavior

Expected both functions to type check

Bug

The trait fails to resolve:

error: No method named 'foo' found for type '(T, U)'
   ┌─ /Users/michaelklein/Coding/noir/equiv_trait_scratch/src/main.nr:31:5
   │
31 │     x.foo(y)
   │     --------
   │

Aborting due to 1 previous error

To Reproduce

Project Impact

Nice-to-have

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS 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 Jun 5, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jun 5, 2024
@asterite asterite self-assigned this Jul 23, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 23, 2024
# Description

## Problem

Resolves #5186

## Summary

Looking for methods that are bound to trait constraints was already
working for `NamedGeneric`, but when the trait is on a composite type,
like `(T, U)` or even `(T, i32)` methods weren't lookup up in
constraints bound to those types.

We only lookup this in case the regular (`lookup_primitive_method`)
lookup fails to find something.

## Additional Context

None.

## Documentation

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 23, 2024
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: Done
Development

Successfully merging a pull request may close this issue.

2 participants