Incorrect mention of .length assignment for dynamically-sized storage arrays in versions of Solidity >= 0.6.0
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
### 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:**
```solidity
// Resizing can be also be done by assigning to `.length` or by assigning to the `slot` member inside inline assembly.
```
**Proposed Updated Code Comment:**
```solidity
// 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.
Contributor guide
Research direction
Open the linked Solidity blog post and locate the quoted comment about resizing dynamic storage arrays. Remove the reference to assigning to `.length`, retain the inline-assembly `slot` wording, and verify the published text matches the proposed correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100