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.
Disallow assigning to fields of non-mutable structs (FuelLabs#1420)
* Disallow assigning to fields of non-mutable structs * Add test for assigning to field of non-mutable struct * fix broken test case that was failing with mutability check * disable broken test blocked on FuelLabs#1188 * disable impl_self_reassignment test This test was failing by trying to assign to a non-mut variable. We need `&mut self` methods before it can be re-enabled. Co-authored-by: Alex Hansen <[email protected]>
- Loading branch information
Showing
8 changed files
with
52 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
File renamed without changes.
File renamed without changes.
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
3 changes: 3 additions & 0 deletions
3
...rc/e2e_vm_tests/test_programs/should_fail/assign_to_field_of_non_mutable_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,3 @@ | ||
[[package]] | ||
name = 'assign_to_field_of_non_mutable_struct' | ||
dependencies = [] |
6 changes: 6 additions & 0 deletions
6
...rc/e2e_vm_tests/test_programs/should_fail/assign_to_field_of_non_mutable_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,6 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
name = "assign_to_field_of_non_mutable_struct" | ||
entry = "main.sw" | ||
implicit-std = false |
11 changes: 11 additions & 0 deletions
11
.../e2e_vm_tests/test_programs/should_fail/assign_to_field_of_non_mutable_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,11 @@ | ||
script; | ||
|
||
struct S { | ||
x: u64, | ||
} | ||
|
||
fn wow() { | ||
let thing: S = S { x: 0 }; | ||
thing.x = 23; | ||
} | ||
|
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 |
---|---|---|
|
@@ -42,7 +42,7 @@ struct S { | |
} | ||
|
||
fn main() -> bool { | ||
let s = S { | ||
let mut s = S { | ||
t0: W { | ||
t5: 5, | ||
t6: T6 { | ||
|