Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Incorrect mention of .length assignment for dynamically-sized storage arrays in versions of Solidity >= 0.6.0 #15480

Open
a1111198 opened this issue Oct 5, 2024 · 0 comments

Comments

@a1111198
Copy link

a1111198 commented Oct 5, 2024

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 .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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@a1111198 and others