Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Type Constructors as Type Arguments #6390

Closed
IGI-111 opened this issue Aug 7, 2024 · 0 comments
Closed

Type Constructors as Type Arguments #6390

IGI-111 opened this issue Aug 7, 2024 · 0 comments
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-024
In Sway one can define generics like the following:

struct S<T> {x: T}

The programmer then needs to provide a concrete type to instantiate the struct.
However, the following is wrongly accepted by Sway:

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

Note that here S does not represent a type but rather a type constructor i.e., an element of the language
that accepts a concrete type T and returns another concrete type S. This shouldn't be accepted.

@IGI-111 IGI-111 added bug Something isn't working P: low audit-report Related to the audit report labels Aug 7, 2024
@IGI-111 IGI-111 assigned IGI-111 and xunilrj and unassigned IGI-111 Aug 22, 2024
IGI-111 added a commit that referenced this issue Aug 28, 2024
## Description

This PR fixes #6383,
#6390 and
#6385.

## Checklist

- [x] I have linked to any relevant issues.
- [x] 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.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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: IGI-111 <igi-111@protonmail.com>
@xunilrj xunilrj closed this as completed Aug 28, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
audit-report Related to the audit report bug Something isn't working P: low
Projects
None yet
Development

No branches or pull requests

2 participants