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.
This PR fixes the bug described in FuelLabs#3891 by adding `ops` to the prelude in `core`. This change is congruent with Rust's approach as well. This is a _breaking change_---if any users have any traits manually implemented for which core already has an existing implementation, this will now create an error. A rightful one, IMO, but a breaking change nonetheless. A few of the tests were written in a way that is not compatible with this change---so this PR rewrites these. The only one of note is that a old `should_pass/language/trait_override_bug` test was refactored to a new `should_fail/redefine_method_from_core` test. This PR also refactors the trait finding algorithm in `check_if_trait_constraints_are_satisfied_for_type` to reduce it from O(n^2) to O(n). Closes FuelLabs#3891 Co-authored-by: emilyaherbert <[email protected]>
- Loading branch information
1 parent
ed1bc39
commit 0ab1d22
Showing
13 changed files
with
86 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ use ::primitives::*; | |
use ::raw_ptr::*; | ||
use ::raw_slice::*; | ||
use ::never::*; | ||
use ::ops::*; |
4 changes: 2 additions & 2 deletions
4
...ass/language/trait_override_bug/Forc.lock → ..._fail/redefine_method_from_core/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,8 +1,8 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-19202DB015C3C015' | ||
source = 'path+from-root-3CA8975A62B42346' | ||
|
||
[[package]] | ||
name = 'trait_override_bug' | ||
name = 'redefine_method_from_core' | ||
source = 'member' | ||
dependencies = ['core'] |
4 changes: 2 additions & 2 deletions
4
...ass/language/trait_override_bug/Forc.toml → ..._fail/redefine_method_from_core/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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[project] | ||
name = "trait_override_bug" | ||
name = "redefine_method_from_core" | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } | ||
core = { path = "../../../../../../sway-lib-core" } |
2 changes: 0 additions & 2 deletions
2
...s/language/trait_override_bug/src/main.sw → ...ail/redefine_method_from_core/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
6 changes: 6 additions & 0 deletions
6
test/src/e2e_vm_tests/test_programs/should_fail/redefine_method_from_core/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,6 @@ | ||
category = "fail" | ||
|
||
# check: $()error | ||
# nextln: main.sw:9:1 | ||
# check: $()impl Shiftable for u64 { | ||
# check: $()Conflicting implementations of trait "Shiftable" for type "u64". |
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
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 |
---|---|---|
|
@@ -5,5 +5,5 @@ use shiftable::*; | |
fn main() { | ||
let mut shiftAnswer: u64 = 0; | ||
|
||
shiftAnswer.rsh(5); | ||
shiftAnswer.my_rsh(5); | ||
} |
12 changes: 6 additions & 6 deletions
12
...c/e2e_vm_tests/test_programs/should_pass/language/trait_import_with_star/src/shiftable.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
25 changes: 0 additions & 25 deletions
25
...c/e2e_vm_tests/test_programs/should_pass/language/trait_override_bug/json_abi_oracle.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/language/trait_override_bug/test.toml
This file was deleted.
Oops, something went wrong.