{ skip to content }

Solidity 0.7.6 Release Announcement

Posted by Solidity Team on December 16, 2020

Releases

Solidity v0.7.6 adds better support for calldata types. Furthermore, the fallback function can now have a parameter and explicitly return data.

Notable New Features

Detection of Overflowing Unicode Direction Markers

The winning entry in the Solidity Underhanded Contest used a clever combination of Unicode direction markers to deceive the reader about the semantics of a time-locked upgrade mechanism. Starting from Solidity 0.7.6, the parser will reject comments and Unicode strings where the text direction is not properly reset before the end of the comment or string.

Better Support for Calldata Types

Since Solidity 0.6.9 you can use calldata as a data location specifier for variables other than parameters of external functions. This release finally adds important missing internal routines that make this feature even more useful:

  • copying dynamically encoded structs and nested arrays from calldata to memory
  • copying array slices from calldata to memory and storage

The first part for example allows calling external functions or internal functions that require complex memory types:

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
pragma abicoder v2;

struct Job {
    uint priority;
    string name;
    bool executed;
}

contract Scheduler {
    function schedule(Job[] calldata _jobs) public {
        for (uint i = 0; i < _jobs.length; i++)
            // This internal function call performs
            // a copy from calldata to memory.
            // The copy in memory will be writable.
            executeJob(_jobs[i]);
    }
    function executeJob(Job memory _job) internal {
        _job.executed = true;
    }
}

The second part allows better access to calldata arrays, even though the implementation for more complex slice types is not finished yet:

function msgDataArguments() pure returns (bytes memory) {
    // This creates a calldata slice starting at the
    // fourth byte and converts it to a memory byte array
    // when returning it.
    return msg.data[4:];
}

Parameters and Return Variables for the Fallback Function

The fallback function can now have a single parameter and a return variable to operate on the low-level data without using inline assembly. The input parameter is essentially an alias for msg.data while the return variable will be returned as a raw byte array without abi encoding.

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
pragma abicoder v2;

contract Proxy {
    address target;
    fallback(bytes calldata _input) external returns (bytes memory) {
        (bool success, bytes memory result) = target.delegatecall(_input);
        if (success)
            // A byte array returned from the fallback function will
            // not be ABI-encoded. If you want to return structured
            // data, you can use ``return abi.encode(x, y)``;
            return result;
        else
            revert(result);
    }
}

Dynamically Load Z3 if Available

The "static" Linux binary is now linked dynamically with glibc >=2.14 (released 2011) which allows it to load libz3.so.4.8 if it is available in your system or simply disable SMTChecker if it is not. Until this release the Linux binary was completely static and came with the SMTChecker features permanently disabled.

Full Changelog

Language Features:

  • Code generator: Support conversion from calldata slices to memory and storage arrays.
  • Code generator: Support copying dynamically encoded structs from calldata to memory.
  • Code generator: Support copying of nested arrays from calldata to memory.
  • Scanner: Generate a parser error when comments or unicode strings contain an unbalanced or underflowing set of unicode direction override markers (LRO, RLO, LRE, RLE, PDF).
  • The fallback function can now also have a single calldata argument (equaling msg.data) and return bytes memory (which will not be ABI-encoded but returned as-is).
  • Wasm backend: Add i32.select and i64.select instructions.

Compiler Features:

  • Build System: Optionally support dynamic loading of Z3 and use that mechanism for Linux release builds.
  • Code Generator: Avoid memory allocation for default value if it is not used.
  • SMTChecker: Apply constant evaluation on binary arithmetic expressions.
  • SMTChecker: Create underflow and overflow verification targets for increment/decrement in the CHC engine.
  • SMTChecker: Report struct values in counterexamples from CHC engine.
  • SMTChecker: Support early returns in the CHC engine.
  • SMTChecker: Support getters.
  • SMTChecker: Support named arguments in function calls.
  • SMTChecker: Support struct constructor.
  • Standard-Json: Move the recently introduced modelCheckerSettings key to settings.modelChecker.
  • Standard-Json: Properly filter the requested output artifacts.

Bugfixes:

  • Code generator: Do not pad empty string literals with a single 32-byte zero field in the ABI coder v1.
  • NatSpec: Fix segfault when inheriting return parameter documentation for modifiers with no parameters.
  • SMTChecker: Fix cast string literals to byte arrays.
  • SMTChecker: Fix internal compiler error when doing bitwise compound assignment with string literals.
  • SMTChecker: Fix internal error when trying to generate counterexamples with old z3.
  • SMTChecker: Fix segmentation fault that could occur on certain SMT-enabled sources when no SMT solver was available.
  • SMTChecker: Fix internal error when bytes.push() is used as the LHS of an assignment.
  • Type Checker: super is not available in libraries.
  • Type Checker: Disallow leading zeroes in sized-types (e.g. bytes000032), but allow them to be treated as identifiers.
  • Yul Optimizer: Fix a bug in NameSimplifier where a new name created by NameSimplifier could also be created by NameDispenser.
  • Yul Optimizer: Removed NameSimplifier from optimization steps available to users.

A big thank you to all contributors who helped make this release possible!

Download the new version of Solidity here.

Previous post

Next post

Get involved

GitHub

Twitter

Mastodon

Matrix

Discover more

BlogDocumentationUse casesContributeAboutForum

2023 Solidity Team

Security Policy

Code of Conduct