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 method Eq not found when used with where clause. (FuelLabs#3348)
The problem was that although two `TypeInfo::UnknownGeneric` were unified they were not regarded as equals by `are_equal_minus_dynamic_types`. Solution was to change how `TypeInfo::UnknownGeneric` are compared in `are_equal_minus_dynamic_types`. Which can now check if two `TypeInfo::UnknownGeneric` were previously unified. This was accomplished by adding two methods to the type engine `insert_unified_type` and `get_unified_types`. Closes FuelLabs#3324
- Loading branch information
Showing
8 changed files
with
117 additions
and
3 deletions.
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
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
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_generic/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-D8A8CF23B4069FF9' | ||
|
||
[[package]] | ||
name = 'eq_generic' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-D8A8CF23B4069FF9' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_generic/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 <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "eq_generic" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
22 changes: 22 additions & 0 deletions
22
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_generic/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": [], | ||
"type": "()", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_generic/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,21 @@ | ||
script; | ||
|
||
use core::ops::*; | ||
|
||
impl<T> Option<T> { | ||
pub fn ok_or<E>(self, err: E) -> Result<T, E> { | ||
match self { | ||
Option::Some(v) => Result::Ok(v), | ||
Option::None => Result::Err(err), | ||
} | ||
} | ||
} | ||
|
||
fn test_ok_or<T, E>(val: T, default: E) where T: Eq { | ||
match Option::Some(val).ok_or(default) { | ||
Result::Ok(inner) => assert(inner == val), | ||
Result::Err(_) => revert(0), | ||
}; | ||
} | ||
|
||
fn main() {} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/eq_generic/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 = 0 } | ||
validate_abi = true |