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

No matching impl found for where clause constraints when using macros #5671

Closed
jfecher opened this issue Aug 2, 2024 · 0 comments · Fixed by #5673
Closed

No matching impl found for where clause constraints when using macros #5671

jfecher opened this issue Aug 2, 2024 · 0 comments · Fixed by #5673
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Aug 2, 2024

Aim

Inserting a trait impl with trait constraints via an attribute:

#[foo]
struct MyOtherStruct<A, B> {
    field1: A,
    field2: B,
}

comptime fn foo(_s: StructDefinition) -> Quoted {
    quote {
        impl<A, B> Eq for MyOtherStruct<A, B> where A: Eq, B: Eq {
            fn eq(self, other: Self) -> bool {
                (self.field1 == other.field1) & (self.field2 == other.field2)
            }
        }
    }
}

fn main() {
    let x = MyOtherStruct { field1: 1, field2: 2 };
    assert_eq(x, x);
}

Expected Behavior

No errors

Bug

error: No matching impl found for `A: Eq`
  ┌─ src/main.nr:1:1
  │  
1 │ ╭ #[foo]
2 │ │ struct MyOtherStruct<A, B> {
3 │ │     field1: A,
4 │ │     field2: B,
5 │ │ }
  │ ╰─' No impl for `A: Eq`
  │  

error: No matching impl found for `B: Eq`
  ┌─ src/main.nr:1:1
  │  
1 │ ╭ #[foo]
2 │ │ struct MyOtherStruct<A, B> {
3 │ │     field1: A,
4 │ │     field2: B,
5 │ │ }
  │ ╰─' No impl for `B: Eq`
  │  

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

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

@jfecher jfecher added the bug Something isn't working label Aug 2, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 2, 2024
# Description

## Problem\*

Resolves #5671

## Summary\*

The issue was that we were adding trait constraints to the methods
themselves in `dc_mod` but this code isn't run for items generated from
attributes which only go through the elaborator. I've just moved this
code to the elaborator instead.

## Additional Context



## 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 Aug 2, 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
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant