forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue of trait implementation not beeing used.
When constraint is used in generic functions the trait name does not contain any prefixes this was causing get_methods_for_type_and_trait_name to return no methods to be used. Closes FuelLabs#3326
- Loading branch information
Showing
6 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_custom_type/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-33945E385D757681' | ||
|
||
[[package]] | ||
name = 'eq_custom_type' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-33945E385D757681' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_custom_type/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "eq_custom_type" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
22 changes: 22 additions & 0 deletions
22
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_custom_type/json_abi_oracle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"functions": [ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"types": [ | ||
{ | ||
"components": null, | ||
"type": "bool", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_custom_type/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
script; | ||
|
||
use core::ops::*; | ||
|
||
enum Error { | ||
BoolError: bool, | ||
U8Error: u8, | ||
} | ||
|
||
impl Eq for Error { | ||
fn eq(self, other: Self) -> bool { | ||
match (self, other) { | ||
(Error::BoolError(val1), Error::BoolError(val2)) => val2 == val1, | ||
(Error::U8Error(val1), Error::U8Error(val2)) => val2 == val1, | ||
_ => false, | ||
} | ||
} | ||
} | ||
|
||
fn test_none_ok_or<T, E>(_val: T, default: E) where E: Eq { | ||
match Option::None::<T>().ok_or(default) { | ||
Result::Ok(_) => revert(0), | ||
Result::Err(e) => assert(default == e), | ||
} | ||
} | ||
|
||
fn main() -> bool { | ||
test_none_ok_or(true, Error::BoolError(true)); | ||
return true; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_custom_type/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 1 } | ||
validate_abi = true |