Incorrect mention of .length assignment for dynamically-sized storage arrays in versions of Solidity >= 0.6.0
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:
"Resizing can be also be done by assigning to
.lengthor by assigning to theslotmember 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.