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

Generics for Structs and Functions #6384

Closed
IGI-111 opened this issue Aug 7, 2024 · 0 comments · Fixed by #6549
Closed

Generics for Structs and Functions #6384

IGI-111 opened this issue Aug 7, 2024 · 0 comments · Fixed by #6549
Assignees
Labels
audit-report Related to the audit report bug Something isn't working P: low

Comments

@IGI-111
Copy link
Contributor

IGI-111 commented Aug 7, 2024

CS-FSSA-018

Users can define generic structs that implement generic functions. For example the following is a valid
Sway program:

script;
struct S<T> {
 x: T,
}
struct M1 {}
impl<T> S<T>
{
 fn bar<M>()
 {
 }
}
fn main() {
 let x = S::<M1>::bar::<M1>();
}

However, if we introduce trait constraints, the compilation fails:

script;
trait MyTrait {
}
struct S<T> {
 x: T,
}
struct M1 {}
impl MyTrait for M1 {
}
impl<T> S<T>
where
 T: MyTrait,
{
 fn bar<M>()
 {
 }
}
fn main() {
 let x = S::<M1>::bar::<M1>();
}
@IGI-111 IGI-111 added bug Something isn't working P: low audit-report Related to the audit report labels Aug 7, 2024
JoshuaBatty added a commit that referenced this issue Sep 18, 2024
## Description

This PR fixes #6384

The performance improvement is probably coming from just aggregating
spans when there is an error.

## Checklist

- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit-report Related to the audit report bug Something isn't working P: low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants