Skip to content

Commit ea4b9e9

Browse files
esdrubalsdankelJoshuaBatty
authored
Adds test for implicit trait constraint. (#6517)
## 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>
1 parent ba153b2 commit ea4b9e9

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[[package]]
2+
name = "core"
3+
source = "path+from-root-3F7C73944D096B89"
4+
5+
[[package]]
6+
name = "implicit_trait_constraint"
7+
source = "member"
8+
dependencies = ["core"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[project]
2+
authors = ["Fuel Labs <contact@fuel.sh>"]
3+
entry = "main.sw"
4+
implicit-std = false
5+
license = "Apache-2.0"
6+
name = "implicit_trait_constraint"
7+
8+
[dependencies]
9+
core = { path = "../../../../../../sway-lib-core" }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
script;
2+
trait T2 {}
3+
trait T1: T2 {
4+
fn new() -> Self;
5+
}
6+
7+
struct S {}
8+
impl T2 for S {}
9+
impl T1 for S {
10+
fn new() -> Self {
11+
S {}
12+
}
13+
}
14+
15+
fn bar<T>() -> T
16+
where
17+
T: T1,
18+
{
19+
T::new()
20+
}
21+
22+
fn foo<T>() -> T
23+
where
24+
T: T2,
25+
{
26+
bar()
27+
}
28+
29+
fn main() -> u64 {
30+
let _:S = foo();
31+
42
32+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
category = "fail"
2+
3+
# check: $()bar()
4+
# nextln: $()Trait "T1" is not implemented for type "T".

0 commit comments

Comments
 (0)