You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Sway, traits can define supertraits. This means that, to implement such a trait for a type, one must
implement its supertrait as well. For example, T2 is a supertrait of T1:
In the above example, let's focus on foo(). foo() is a generic function, whose type parameter T just
has to implement T2. In its implementation, foo() calls bar() and returns its result: type inference
therefore implies that the same type T should also parametrise the call to bar(). However, foo()
additionally requires that its type parameter implement T1: this constraint is not automatically satisfied for
all types T that implement T2, so compilation should fail. Instead, the program is accepted by the
compiler.
Taking this a step further, if one adds let s: S = foo(); to the main(), so as to actually trigger a
call to a non-existent function, the compiler runs into an ICE:
Internal compiler error: Method new_3 is a trait method dummy and was not properly replaced.
Please file an issue on the repository and include the code that triggered this error.
For reference, Rust prohibits the above snippet and requires to add an explicit trait bound T1 for foo().
The text was updated successfully, but these errors were encountered:
This PR adds test that proves implicit trait constraint already returns
an error. The method dummy ICE reported in #6377 was fixed by #6490.
Closes#6377.
## Description
This PR adds a test that proves implicit trait constraint already
returns
an error. The method dummy ICE reported in #6377 was fixed by #6490.
Closes#6377.
## 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.
- [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: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
CS-FSSA-011
In Sway, traits can define supertraits. This means that, to implement such a trait for a type, one must
implement its supertrait as well. For example, T2 is a supertrait of T1:
In the above example, let's focus on foo(). foo() is a generic function, whose type parameter T just
has to implement T2. In its implementation, foo() calls bar() and returns its result: type inference
therefore implies that the same type T should also parametrise the call to bar(). However, foo()
additionally requires that its type parameter implement T1: this constraint is not automatically satisfied for
all types T that implement T2, so compilation should fail. Instead, the program is accepted by the
compiler.
Taking this a step further, if one adds let s: S = foo(); to the main(), so as to actually trigger a
call to a non-existent function, the compiler runs into an ICE:
Internal compiler error: Method new_3 is a trait method dummy and was not properly replaced.
Please file an issue on the repository and include the code that triggered this error.
For reference, Rust prohibits the above snippet and requires to add an explicit trait bound T1 for foo().
The text was updated successfully, but these errors were encountered: