Version 0.6.5 of Solidity fixes an important bug and introduces
immutable as a major feature.
The bug concerns the allocation of dynamic memory arrays using e.g.
new uint(...). The bug is considered to have a severity level of “low” but is present in all prior versions of Solidity. Therefore, please read more about how check if your contract is vulnerable in this blog post.
The immutable feature supports setting contract-level variables at construction time if they do not change later on. These variables are stored directly in the code instead of storage, which makes them extremely cheap to use. For now, only value types are supported.
- Code Generator: Restrict the length of dynamic memory arrays to 64 bits during creation at runtime fixing a possible overflow.
- Allow local storage variables to be declared without initialization, as long as they are assigned before they are accessed.
- State variables can be marked
immutablewhich causes them to be read-only, but assignable in the constructor. The value will be stored directly in the code.
- Commandline Interface: Enable output of storage layout with
- Metadata: Added support for IPFS hashes of large files that need to be split in multiple chunks.
- Inheritance: Allow public state variables to override functions with dynamic memory types in their return values.
- Inline Assembly: Fix internal error when accessing invalid constant variables.
- Inline Assembly: Fix internal error when accessing functions.
- JSON AST: Always add pointer suffix for memory reference types.
- Reference Resolver: Fix internal error when accessing invalid struct members.
- Type Checker: Fix internal errors when assigning nested tuples.
A big thank you to all contributors who helped make this release possible!
Download the new version of Solidity here.