Skip to content

Lift restrictions against allocating the last storage slot #15911

Open
@cameel

Description

@cameel

Currently, defining a storage variable that covers the last storage slot results in a compilation error. Either when contract's variables are so large that they cover the whole storage (this is already possible) or when the layout base is shifted so much that reasonably-sized variables reach the last slot (which will be possible after #597).

It's not clear why the restriction was added. It may have been done to keep the last slot reserved, but this wasn't documented anywhere, so it could just as well have been be a mistake.

We should remove the restriction.

Steps to reproduce

Oversized array

contract C {
    uint[2**256] x;
}
Error: Array length too large, maximum is 2**256 - 1.
 --> test.sol:2:10:
  |
2 |     uint[2**256] x;
  |          ^^^^^^

Layout

contract D layout at 2**256 - 1 {
    uint x;
}
Error: Contract extends past the end of storage when this base slot value is specified.
 --> test.sol:1:22:
  |
1 | contract D layout at 2**256 - 1 {
  |                      ^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    low effortThere is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions