Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Mutability for Immutable Composite Types #6368

Closed
IGI-111 opened this issue Aug 7, 2024 · 0 comments · Fixed by #6415
Closed

Mutability for Immutable Composite Types #6368

IGI-111 opened this issue Aug 7, 2024 · 0 comments · Fixed by #6415
Assignees
Labels
audit-report Related to the audit report bug Something isn't working P: high Should be looked at if there are no critical issues left

Comments

@IGI-111
Copy link
Contributor

IGI-111 commented Aug 7, 2024

CS-FSSA-002

In Sway, mutability is specified upon declaration. In case a variable is defined as immutable, its content
cannot be changed. However, the mutability check is not recursive on composite types. This means we
can create a mutable reference to a field of an immutable variable like the following example:

let t : (u64, u64) = (17, 42);
let p : &mut u64 = &mut t.0;
*p = 18;
@IGI-111 IGI-111 added audit-report Related to the audit report bug Something isn't working P: high Should be looked at if there are no critical issues left labels Aug 7, 2024
@tritao tritao closed this as completed in 1c275bc Aug 15, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
audit-report Related to the audit report bug Something isn't working P: high Should be looked at if there are no critical issues left
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants