-
Notifications
You must be signed in to change notification settings - Fork 225
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
Traits should allow methods with generic return types #3474
Labels
bug
Something isn't working
Comments
grasshopper47
changed the title
Traits should allow generic return types to methods
Traits should allow methods with generic return types
Nov 10, 2023
Closing as duplicate of #3479 |
Reopening as they're actually slightly different. |
github-merge-queue bot
pushed a commit
that referenced
this issue
Jan 16, 2024
# Description ## Problem\* Resolves #3471 Resolves #3474 ## Summary\* Implements support for generics on the trait directly. E.g. `trait Into<T> { ... }` ## Additional Context The old `trait_generics` test has been renamed to `trait_impl_generics` - I think this is more accurate. There is a new test in `trait_generics` now which tests the generic traits added by this PR. I've discovered two new bugs in writing this PR, which are commented in the `trait_generics` test. I'll make issues for them now. ## Documentation\* Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aim
Currently it is possible to use generics within a trait:
Expected Behavior
A trait allows methods with a generic return type:
Bug
When creating the implementation the compiler throws a confusing error:
Linked issue: #3502
To Reproduce
Compile the following:
Installation Method
Binary
Nargo Version
0.19.2
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: