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.
Prevent stack overflow when defining a trait method with certain types (
FuelLabs#3280) This PR fixes a bug that was causing a stack overflow when a trait method impl differentiated from a trait method definition. The fix was to draw a direct comparison between the expected type (the type from the definition) and the found type (the type from the impl) instead of trying to unify the found type into the expected type. Closes FuelLabs#3271
- Loading branch information
1 parent
3bd7118
commit c9565f8
Showing
7 changed files
with
71 additions
and
36 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
15 changes: 9 additions & 6 deletions
15
test/src/e2e_vm_tests/test_programs/should_fail/abi_method_signature_mismatch/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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
category = "fail" | ||
|
||
# check: fn foo(s: str[7]) -> str[7] { | ||
# check: $()Expected: u64 | ||
# check: $()found: str[7]. The definition of this function must match the one in the ABI "MyContract" declaration. | ||
# check: $()expected: u64 | ||
# check: $()found: str[7] | ||
# check: $()The definition of this function must match the one in the ABI "MyContract" declaration. | ||
|
||
# check: fn bar() -> u64 { | ||
# check: $()Expected: u32 | ||
# check: $()found: u64. The definition of this function must match the one in the ABI "MyContract" declaration. | ||
# nextln: $()expected: u32 | ||
# nextln: $()found: u64 | ||
# nextln: $()The definition of this function must match the one in the ABI "MyContract" declaration. | ||
|
||
# check: fn baz() { | ||
# check: $()Expected: u64 | ||
# check: $()found: (). The definition of this function must match the one in the ABI "MyContract" declaration. | ||
# nextln: $()expected: u64 | ||
# nextln: $()found: () | ||
# nextln: $()The definition of this function must match the one in the ABI "MyContract" declaration. |
10 changes: 10 additions & 0 deletions
10
test/src/e2e_vm_tests/test_programs/should_fail/trait_method_signature_mismatch/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 |
---|---|---|
@@ -1,3 +1,13 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-67618F664448A0EB' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-67618F664448A0EB' | ||
dependencies = ['core'] | ||
|
||
[[package]] | ||
name = 'trait_method_signature_mismatch' | ||
source = 'member' | ||
dependencies = ['std'] |
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 |
---|---|---|
|
@@ -3,4 +3,6 @@ authors = ["Fuel Labs <[email protected]>"] | |
license = "Apache-2.0" | ||
name = "trait_method_signature_mismatch" | ||
entry = "main.sw" | ||
implicit-std = false | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../sway-lib-std" } |
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
20 changes: 14 additions & 6 deletions
20
test/src/e2e_vm_tests/test_programs/should_fail/trait_method_signature_mismatch/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 |
---|---|---|
@@ -1,16 +1,24 @@ | ||
category = "fail" | ||
|
||
# check: $()fn set(self, val: Option<T>) { | ||
# check: $()expected: T | ||
# check: $()found: Option<T> | ||
# check: $()help: The definition of this function must match the one in the trait "MyTrait" declaration. | ||
|
||
# check: fn foo(s: str[7]) -> str[7] { | ||
# check: $()Expected: u64 | ||
# check: $()found: str[7]. The definition of this function must match the one in the trait "Foo" declaration. | ||
# nextln: $()expected: u64 | ||
# nextln: $()found: str[7] | ||
# nextln: $()The definition of this function must match the one in the trait "Foo" declaration. | ||
|
||
# check: fn bar(ref mut variable: u64) -> bool { | ||
# check: $()Parameter mutability mismatch between the trait function declaration and its implementation. | ||
|
||
# check: fn baz() -> u64 { | ||
# check: $()Expected: u32 | ||
# check: $()found: u64. The definition of this function must match the one in the trait "Foo" declaration. | ||
# nextln: $()expected: u32 | ||
# nextln: $()found: u64 | ||
# nextln: $()The definition of this function must match the one in the trait "Foo" declaration. | ||
|
||
# check: fn quux() { | ||
# check: $()Expected: u64 | ||
# check: $()found: (). The definition of this function must match the one in the trait "Foo" declaration. | ||
# nextln: $()expected: u64 | ||
# nextln: $()found: () | ||
# nextln: $()The definition of this function must match the one in the trait "Foo" declaration. |