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 struct and enum call path comparison to use suffix. (FuelLabs#4133
) ## Description The issue is that currently call paths of structs and enums are based on module path which can differ depending on the order of imports. The solution was to revert to the old behavior of comparing only the type name contained in the suffix. Closes FuelLabs#4125 ## Checklist - [x] I have linked to any relevant issues. - [ ] 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). - [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: Mohammad Fawaz <[email protected]>
- Loading branch information
1 parent
8bef89c
commit 72503fc
Showing
9 changed files
with
126 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
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/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-B1BD953F42F45255' | ||
|
||
[[package]] | ||
name = 'return_struct' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-B1BD953F42F45255' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/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]>"] | ||
license = "Apache-2.0" | ||
name = "return_struct" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
69 changes: 69 additions & 0 deletions
69
.../e2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/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,69 @@ | ||
{ | ||
"configurables": [], | ||
"functions": [ | ||
{ | ||
"attributes": [ | ||
{ | ||
"arguments": [ | ||
"read" | ||
], | ||
"name": "storage" | ||
} | ||
], | ||
"inputs": [], | ||
"name": "test_function", | ||
"output": { | ||
"name": "", | ||
"type": 1, | ||
"typeArguments": [ | ||
{ | ||
"name": "", | ||
"type": 3, | ||
"typeArguments": null | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"messagesTypes": [], | ||
"types": [ | ||
{ | ||
"components": [], | ||
"type": "()", | ||
"typeId": 0, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"components": [ | ||
{ | ||
"name": "None", | ||
"type": 0, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "Some", | ||
"type": 2, | ||
"typeArguments": null | ||
} | ||
], | ||
"type": "enum Option", | ||
"typeId": 1, | ||
"typeParameters": [ | ||
2 | ||
] | ||
}, | ||
{ | ||
"components": null, | ||
"type": "generic T", | ||
"typeId": 2, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"components": [], | ||
"type": "struct MyStruct", | ||
"typeId": 3, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/src/data_structures.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,3 @@ | ||
library data_structures; | ||
|
||
pub struct MyStruct {} |
10 changes: 10 additions & 0 deletions
10
.../src/e2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/src/interface.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,10 @@ | ||
library interface; | ||
|
||
dep data_structures; | ||
|
||
use data_structures::MyStruct; | ||
|
||
abi MyContract { | ||
#[storage(read)] | ||
fn test_function() -> Option<MyStruct>; | ||
} |
18 changes: 18 additions & 0 deletions
18
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/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,18 @@ | ||
contract; | ||
|
||
dep interface; | ||
dep data_structures; | ||
|
||
use interface::MyContract; | ||
use data_structures::MyStruct; | ||
|
||
storage { | ||
a: StorageMap<u64, MyStruct> = StorageMap {} | ||
} | ||
|
||
impl MyContract for Contract { | ||
#[storage(read)] | ||
fn test_function() -> Option<MyStruct> { | ||
storage.a.get(1) | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/return_struct/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,2 @@ | ||
category = "compile" | ||
validate_abi = true |