You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The blog post on the dynamic array cleanup bug in Solidity mentions resizing arrays by assigning to .length. However, this is misleading for versions of Solidity >= 0.6.0, as .length has been made read-only for storage arrays. Specifically, the following comment should be corrected:
"Resizing can be also be done by assigning to .length or by assigning to the slot member inside inline assembly."
In versions >= 0.6.0, .length is read-only and cannot be used to modify the size of a dynamically-sized storage array. Therefore, this should be corrected to avoid confusion.
Proposed Correction
Remove the reference to .length in the comment and keep only the mention of resizing using inline assembly.
Pull Request
Since this is related to a blog post, I could not create a direct pull request. However, I'm providing the proposed changes here:
Original Code Comment:
// Resizing can be also be done by assigning to `.length` or by assigning to the `slot` member inside inline assembly.
Proposed Updated Code Comment:
// Resizing can also be done by assigning to the `slot` member inside inline assembly.
This change ensures that the blog post is aligned with the Solidity language behavior for newer versions and avoids confusion for developers using versions >= 0.6.0.
The text was updated successfully, but these errors were encountered:
Page
https://soliditylang.org/blog/2020/10/07/solidity-dynamic-array-cleanup-bug/
Abstract
The blog post on the dynamic array cleanup bug in Solidity mentions resizing arrays by assigning to
.length
. However, this is misleading for versions of Solidity >= 0.6.0, as.length
has been made read-only for storage arrays. Specifically, the following comment should be corrected:In versions >= 0.6.0,
.length
is read-only and cannot be used to modify the size of a dynamically-sized storage array. Therefore, this should be corrected to avoid confusion.Proposed Correction
Remove the reference to
.length
in the comment and keep only the mention of resizing using inline assembly.Pull Request
Since this is related to a blog post, I could not create a direct pull request. However, I'm providing the proposed changes here:
Original Code Comment:
// Resizing can be also be done by assigning to `.length` or by assigning to the `slot` member inside inline assembly.
Proposed Updated Code Comment:
// Resizing can also be done by assigning to the `slot` member inside inline assembly.
This change ensures that the blog post is aligned with the Solidity language behavior for newer versions and avoids confusion for developers using versions >= 0.6.0.
The text was updated successfully, but these errors were encountered: