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 application self mutability check. (FuelLabs#4538)
## Description We now check method application self parameters mutability when the used arguments is a `StructFieldAccess`. When a `StructFieldAccess` is used to call a method application with a mutable self we now make sure that the `StructFieldAccess` prefix variable is also mutable. Closes FuelLabs#4408 ## Checklist - [x] I have linked to any relevant issues. - [x] 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.
- Loading branch information
Showing
3 changed files
with
82 additions
and
27 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
9 changes: 8 additions & 1 deletion
9
test/src/e2e_vm_tests/test_programs/should_fail/method_requires_mut_var/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,3 +1,10 @@ | ||
category = "fail" | ||
|
||
# check: $()Cannot call method "f" on variable "a" because "a" is not declared as mutable. | ||
# check: $()self.a.f(); | ||
# nextln: $()Cannot call method "f" on variable "self" because "self" is not declared as mutable. | ||
|
||
# check: $()self.b.a.f(); | ||
# nextln: $()Cannot call method "f" on variable "self" because "self" is not declared as mutable. | ||
|
||
# check: $()a.f(); | ||
# nextln: $()Cannot call method "f" on variable "a" because "a" is not declared as mutable. |