Merge pull request #8053 from ethereum/prepare-version-070

Prepare 0.7.0
This commit is contained in:
chriseth 2020-01-14 16:41:44 +01:00 committed by GitHub
commit 7554658efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 155 additions and 145 deletions

View File

@ -10,7 +10,7 @@ include(EthPolicy)
eth_policy() eth_policy()
# project name and version should be set after cmake_policy CMP0048 # project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.6.1") set(PROJECT_VERSION "0.7.0")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
include(TestBigEndian) include(TestBigEndian)

View File

@ -1,3 +1,15 @@
### 0.7.0 (unreleased)
Language Features:
Compiler Features:
Bugfixes:
### 0.6.1 (unreleased) ### 0.6.1 (unreleased)
Language Features: Language Features:

View File

@ -36,7 +36,7 @@ found in the [Solidity documentation](https://solidity.readthedocs.io/en/latest/
A "Hello World" program in Solidity is of even less use than in other languages, but still: A "Hello World" program in Solidity is of even less use than in other languages, but still:
```solidity ```solidity
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
contract HelloWorld { contract HelloWorld {
function helloWorld() external pure returns (string memory) { function helloWorld() external pure returns (string memory) {

View File

@ -308,7 +308,7 @@ This will no longer compile with Solidity v0.5.0. However, you can define a comp
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
interface OldContract { interface OldContract {
function someOldFunction(uint8 a) external; function someOldFunction(uint8 a) external;
function anotherOldFunction() external returns (bool); function anotherOldFunction() external returns (bool);
@ -325,7 +325,7 @@ Given the interface defined above, you can now easily use the already deployed p
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
interface OldContract { interface OldContract {
function someOldFunction(uint8 a) external; function someOldFunction(uint8 a) external;
@ -431,7 +431,7 @@ New version:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract OtherContract { contract OtherContract {
uint x; uint x;

View File

@ -232,7 +232,7 @@ Given the contract:
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract Foo { contract Foo {
@ -532,7 +532,7 @@ For example,
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Test { contract Test {
@ -580,7 +580,7 @@ As an example, the code
:: ::
pragma solidity >=0.4.19 <0.7.0; pragma solidity >=0.4.19 <0.8.0;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;

View File

@ -72,7 +72,7 @@ without a compiler change.
.. code:: .. code::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
library GetCode { library GetCode {
function at(address _addr) public view returns (bytes memory o_code) { function at(address _addr) public view returns (bytes memory o_code) {
@ -97,7 +97,7 @@ efficient code, for example:
.. code:: .. code::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
library VectorSum { library VectorSum {
@ -385,7 +385,7 @@ Local Solidity variables are available for assignments, for example:
.. code:: .. code::
pragma solidity >=0.4.11 <0.7.0; pragma solidity >=0.4.11 <0.8.0;
contract C { contract C {
uint b; uint b;
@ -425,7 +425,7 @@ declaration visible in the scope of the inline assembly block.
.. code:: .. code::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
function f(uint x) public view returns (uint b) { function f(uint x) public view returns (uint b) {
@ -689,7 +689,7 @@ Example:
We will follow an example compilation from Solidity to assembly. We will follow an example compilation from Solidity to assembly.
We consider the runtime bytecode of the following Solidity program:: We consider the runtime bytecode of the following Solidity program::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {

View File

@ -27,7 +27,7 @@ you receive the funds of the person who is now the richest.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract WithdrawalContract { contract WithdrawalContract {
address public richest; address public richest;
@ -60,7 +60,7 @@ This is as opposed to the more intuitive sending pattern:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract SendContract { contract SendContract {
address payable public richest; address payable public richest;
@ -121,7 +121,7 @@ restrictions highly readable.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract AccessRestriction { contract AccessRestriction {
// These will be assigned at the construction // These will be assigned at the construction
@ -273,7 +273,7 @@ function finishes.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract StateMachine { contract StateMachine {
enum Stages { enum Stages {

View File

@ -13,7 +13,7 @@ This can be done by using the ``abstract`` keyword as shown in the following exa
defined as abstract, because the function ``utterance()`` was defined, but no implementation was defined as abstract, because the function ``utterance()`` was defined, but no implementation was
provided (no implementation body ``{ }`` was given).:: provided (no implementation body ``{ }`` was given).::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
abstract contract Feline { abstract contract Feline {
function utterance() public virtual returns (bytes32); function utterance() public virtual returns (bytes32);
@ -22,7 +22,7 @@ provided (no implementation body ``{ }`` was given).::
Such abstract contracts can not be instantiated directly. This is also true, if an abstract contract itself does implement Such abstract contracts can not be instantiated directly. This is also true, if an abstract contract itself does implement
all defined functions. The usage of an abstract contract as a base class is shown in the following example:: all defined functions. The usage of an abstract contract as a base class is shown in the following example::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
abstract contract Feline { abstract contract Feline {
function utterance() public virtual returns (bytes32); function utterance() public virtual returns (bytes32);

View File

@ -26,7 +26,7 @@ value types and strings.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
uint constant x = 32**22 + 8; uint constant x = 32**22 + 8;

View File

@ -34,7 +34,7 @@ This means that cyclic creation dependencies are impossible.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract OwnedToken { contract OwnedToken {

View File

@ -65,7 +65,7 @@ is that they are cheaper to deploy and call.
:: ::
pragma solidity >=0.4.21 <0.7.0; pragma solidity >=0.4.21 <0.8.0;
contract ClientReceipt { contract ClientReceipt {
event Deposit( event Deposit(
@ -138,7 +138,7 @@ as topics. The event call above can be performed in the same way as
:: ::
pragma solidity >=0.4.10 <0.7.0; pragma solidity >=0.4.10 <0.8.0;
contract C { contract C {
function f() public payable { function f() public payable {

View File

@ -17,7 +17,7 @@ if they are marked ``virtual``. For details, please see
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract owned { contract owned {
constructor() public { owner = msg.sender; } constructor() public { owner = msg.sender; }

View File

@ -23,7 +23,7 @@ unused parameters can be omitted.
For example, if you want your contract to accept one kind of external call For example, if you want your contract to accept one kind of external call
with two integers, you would use something like the following:: with two integers, you would use something like the following::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract Simple { contract Simple {
uint sum; uint sum;
@ -55,7 +55,7 @@ Function return variables are declared with the same syntax after the
For example, suppose you want to return two results: the sum and the product of For example, suppose you want to return two results: the sum and the product of
two integers passed as function parameters, then you use something like:: two integers passed as function parameters, then you use something like::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract Simple { contract Simple {
function arithmetic(uint _a, uint _b) function arithmetic(uint _a, uint _b)
@ -79,7 +79,7 @@ or you can provide return values
(either a single or :ref:`multiple ones<multi-return>`) directly with the ``return`` (either a single or :ref:`multiple ones<multi-return>`) directly with the ``return``
statement:: statement::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract Simple { contract Simple {
function arithmetic(uint _a, uint _b) function arithmetic(uint _a, uint _b)
@ -142,7 +142,7 @@ The following statements are considered modifying the state:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract C { contract C {
function f(uint a, uint b) public view returns (uint) { function f(uint a, uint b) public view returns (uint) {
@ -187,7 +187,7 @@ In addition to the list of state modifying statements explained above, the follo
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract C { contract C {
function f(uint a, uint b) public pure returns (uint) { function f(uint a, uint b) public pure returns (uint) {
@ -280,7 +280,7 @@ Below you can see an example of a Sink contract that uses function ``receive``.
:: ::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
// This contract keeps all Ether sent to it with no way // This contract keeps all Ether sent to it with no way
// to get it back. // to get it back.
@ -335,7 +335,7 @@ operations as long as there is enough gas passed on to it.
:: ::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
contract Test { contract Test {
// This function is called for all messages sent to // This function is called for all messages sent to
@ -407,7 +407,7 @@ The following example shows overloading of the function
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract A { contract A {
function f(uint _in) public pure returns (uint out) { function f(uint _in) public pure returns (uint out) {
@ -425,7 +425,7 @@ externally visible functions differ by their Solidity types but not by their ext
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
// This will not compile // This will not compile
contract A { contract A {
@ -458,7 +458,7 @@ candidate, resolution fails.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract A { contract A {
function f(uint8 _in) public pure returns (uint8 out) { function f(uint8 _in) public pure returns (uint8 out) {

View File

@ -38,7 +38,7 @@ Details are given in the following example.
:: ::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
contract Owned { contract Owned {
@ -125,7 +125,7 @@ Note that above, we call ``mortal.kill()`` to "forward" the
destruction request. The way this is done is problematic, as destruction request. The way this is done is problematic, as
seen in the following example:: seen in the following example::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
contract owned { contract owned {
constructor() public { owner = msg.sender; } constructor() public { owner = msg.sender; }
@ -154,7 +154,7 @@ A call to ``Final.kill()`` will call ``Base2.kill`` because we specify it
explicitly in the final override, but this function will bypass explicitly in the final override, but this function will bypass
``Base1.kill``. The way around this is to use ``super``:: ``Base1.kill``. The way around this is to use ``super``::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract owned { contract owned {
constructor() public { owner = msg.sender; } constructor() public { owner = msg.sender; }
@ -204,7 +204,7 @@ use the ``override`` keyword in the function header as shown in this example:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Base contract Base
{ {
@ -227,7 +227,7 @@ bases, it has to explicitly override it:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Base1 contract Base1
{ {
@ -253,7 +253,7 @@ that already overrides all other functions.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract A { function f() public pure{} } contract A { function f() public pure{} }
contract B is A {} contract B is A {}
@ -293,7 +293,7 @@ of the variable:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract A contract A
{ {
@ -324,7 +324,7 @@ and the ``override`` keyword must be used in the overriding modifier:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Base contract Base
{ {
@ -342,7 +342,7 @@ explicitly:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Base1 contract Base1
{ {
@ -389,7 +389,7 @@ equivalent to ``constructor() public {}``. For example:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract A { contract A {
uint public a; uint public a;
@ -419,7 +419,7 @@ The constructors of all the base contracts will be called following the
linearization rules explained below. If the base constructors have arguments, linearization rules explained below. If the base constructors have arguments,
derived contracts need to specify all of them. This can be done in two ways:: derived contracts need to specify all of them. This can be done in two ways::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract Base { contract Base {
uint x; uint x;
@ -478,7 +478,7 @@ error "Linearization of inheritance graph impossible".
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract X {} contract X {}
contract A is X {} contract A is X {}
@ -498,7 +498,7 @@ One area where inheritance linearization is especially important and perhaps not
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract Base1 { contract Base1 {
constructor() public {} constructor() public {}

View File

@ -22,7 +22,7 @@ Interfaces are denoted by their own keyword:
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
interface Token { interface Token {
enum TokenType { Fungible, NonFungible } enum TokenType { Fungible, NonFungible }

View File

@ -47,7 +47,7 @@ more advanced example to implement a set).
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
// We define a new struct datatype that will be used to // We define a new struct datatype that will be used to
@ -123,7 +123,7 @@ custom types without the overhead of external function calls:
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
struct bigint { struct bigint {
uint[] limbs; uint[] limbs;
@ -237,7 +237,7 @@ Its value can be obtained from Solidity using the ``.selector`` member as follow
:: ::
pragma solidity >0.5.13 <0.7.0; pragma solidity >0.5.13 <0.8.0;
library L { library L {
function f(uint256) external {} function f(uint256) external {}

View File

@ -29,7 +29,7 @@ may only be used inside a contract, not inside any of its functions.
Let us rewrite the set example from the Let us rewrite the set example from the
:ref:`libraries` in this way:: :ref:`libraries` in this way::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
// This is the same code as before, just without comments // This is the same code as before, just without comments
@ -81,7 +81,7 @@ Let us rewrite the set example from the
It is also possible to extend elementary types in that way:: It is also possible to extend elementary types in that way::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
library Search { library Search {
function indexOf(uint[] storage self, uint value) function indexOf(uint[] storage self, uint value)

View File

@ -54,7 +54,7 @@ return parameter list for functions.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
function f(uint a) private pure returns (uint b) { return a + 1; } function f(uint a) private pure returns (uint b) { return a + 1; }
@ -68,7 +68,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
uint private data; uint private data;
@ -112,7 +112,7 @@ when they are declared.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
uint public data = 42; uint public data = 42;
@ -132,7 +132,7 @@ it evaluates to a state variable. If it is accessed externally
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
uint public data; uint public data;
@ -151,7 +151,7 @@ to write a function, for example:
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract arrayExample { contract arrayExample {
// public state variable // public state variable
@ -177,7 +177,7 @@ The next example is more complex:
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract Complex { contract Complex {
struct Data { struct Data {

View File

@ -422,7 +422,7 @@ or ``interface`` using the ``./test/cmdlineTests.sh`` script when you create a P
ensure they work and pass tests before creating the PR. ensure they work and pass tests before creating the PR.
Ensure that all code examples begin with a ``pragma`` version that spans the largest where the contract code is valid. Ensure that all code examples begin with a ``pragma`` version that spans the largest where the contract code is valid.
For example ``pragma solidity >=0.4.0 <0.7.0;``. For example ``pragma solidity >=0.4.0 <0.8.0;``.
Running Documentation Tests Running Documentation Tests
--------------------------- ---------------------------

View File

@ -41,7 +41,7 @@ Internal Function Calls
Functions of the current contract can be called directly ("internally"), also recursively, as seen in Functions of the current contract can be called directly ("internally"), also recursively, as seen in
this nonsensical example:: this nonsensical example::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
function g(uint a) public pure returns (uint ret) { return a + f(); } function g(uint a) public pure returns (uint ret) { return a + f(); }
@ -81,7 +81,7 @@ of the contract:
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract InfoFeed { contract InfoFeed {
function info() public payable returns (uint ret) { return 42; } function info() public payable returns (uint ret) { return 42; }
@ -131,7 +131,7 @@ parameters from the function declaration, but can be in arbitrary order.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
mapping(uint => uint) data; mapping(uint => uint) data;
@ -154,7 +154,7 @@ Those parameters will still be present on the stack, but they are inaccessible.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
// omitted name for parameter // omitted name for parameter
@ -177,7 +177,7 @@ is compiled so recursive creation-dependencies are not possible.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract D { contract D {
uint public x; uint public x;
@ -237,7 +237,7 @@ groupings of expressions.
:: ::
pragma solidity >0.4.23 <0.7.0; pragma solidity >0.4.23 <0.8.0;
contract C { contract C {
uint index; uint index;
@ -292,7 +292,7 @@ because only a reference and not a copy is passed.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
uint[20] x; uint[20] x;
@ -350,7 +350,7 @@ the two variables have the same name but disjoint scopes.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract C { contract C {
function minimalScoping() pure public { function minimalScoping() pure public {
{ {
@ -371,7 +371,7 @@ In any case, you will get a warning about the outer variable being shadowed.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
// This will report a warning // This will report a warning
contract C { contract C {
function f() pure public returns (uint) { function f() pure public returns (uint) {
@ -392,7 +392,7 @@ In any case, you will get a warning about the outer variable being shadowed.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
// This will not compile // This will not compile
contract C { contract C {
function f() pure public returns (uint) { function f() pure public returns (uint) {
@ -480,7 +480,7 @@ and ``assert`` for internal error checking.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Sharer { contract Sharer {
function sendHalf(address payable addr) public payable returns (uint balance) { function sendHalf(address payable addr) public payable returns (uint balance) {
@ -524,7 +524,7 @@ The following example shows how to use an error string together with ``revert``
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract VendingMachine { contract VendingMachine {
function buy(uint amount) public payable { function buy(uint amount) public payable {
@ -567,7 +567,7 @@ A failure in an external call can be caught using a try/catch statement, as foll
:: ::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
interface DataFeed { function getData(address token) external returns (uint value); } interface DataFeed { function getData(address token) external returns (uint value); }

View File

@ -24,7 +24,7 @@ to receive their money - contracts cannot activate themselves.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract SimpleAuction { contract SimpleAuction {
// Parameters of the auction. Times are either // Parameters of the auction. Times are either
@ -184,7 +184,7 @@ invalid bids.
:: ::
pragma solidity >0.4.23 <0.7.0; pragma solidity >0.4.23 <0.8.0;
contract BlindAuction { contract BlindAuction {
struct Bid { struct Bid {

View File

@ -142,7 +142,7 @@ The full contract
:: ::
pragma solidity >=0.4.24 <0.7.0; pragma solidity >=0.4.24 <0.8.0;
contract ReceiverPays { contract ReceiverPays {
address owner = msg.sender; address owner = msg.sender;
@ -338,7 +338,7 @@ The full contract
:: ::
pragma solidity >=0.4.24 <0.7.0; pragma solidity >=0.4.24 <0.8.0;
contract SimplePaymentChannel { contract SimplePaymentChannel {
address payable public sender; // The account sending payments. address payable public sender; // The account sending payments.

View File

@ -19,7 +19,7 @@ and the sum of all balances is an invariant across the lifetime of the contract.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
library Balances { library Balances {
function move(mapping(address => uint256) storage balances, address from, address to, uint amount) internal { function move(mapping(address => uint256) storage balances, address from, address to, uint amount) internal {

View File

@ -25,7 +25,7 @@ you can use state machine-like constructs inside a contract.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract Purchase { contract Purchase {
uint public value; uint public value;

View File

@ -32,7 +32,7 @@ of votes.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
/// @title Voting with delegation. /// @title Voting with delegation.
contract Ballot { contract Ballot {

View File

@ -17,7 +17,7 @@ Storage Example
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract SimpleStorage { contract SimpleStorage {
uint storedData; uint storedData;
@ -77,7 +77,7 @@ registering with a username and password, all you need is an Ethereum keypair.
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Coin { contract Coin {
// The keyword "public" makes variables // The keyword "public" makes variables

View File

@ -284,7 +284,7 @@ for the two function parameters and two return variables.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
/** @title Shape calculator. */ /** @title Shape calculator. */
contract ShapeCalculator { contract ShapeCalculator {

View File

@ -75,7 +75,7 @@ So for the following contract snippet
the position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``:: the position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
@ -175,7 +175,7 @@ value and reference types, types that are encoded packed, and nested types.
.. code:: .. code::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract A { contract A {
struct S { struct S {
uint128 a; uint128 a;

View File

@ -49,7 +49,7 @@ The following example shows a contract and a function using all available tags.
.. code:: solidity .. code:: solidity
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
/// @title A simulator for trees /// @title A simulator for trees
/// @author Larry A. Gardner /// @author Larry A. Gardner

View File

@ -58,7 +58,7 @@ complete contract):
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE // THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract Fund { contract Fund {
@ -81,7 +81,7 @@ as it uses ``call`` which forwards all remaining gas by default:
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE // THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract Fund { contract Fund {
@ -100,7 +100,7 @@ outlined further below:
:: ::
pragma solidity >=0.4.11 <0.7.0; pragma solidity >=0.4.11 <0.8.0;
contract Fund { contract Fund {
/// Mapping of ether shares of the contract. /// Mapping of ether shares of the contract.
@ -197,7 +197,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE // THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract TxUserWallet { contract TxUserWallet {
@ -217,7 +217,7 @@ Now someone tricks you into sending Ether to the address of this attack wallet:
:: ::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
interface TxUserWallet { interface TxUserWallet {
function transferTo(address payable dest, uint amount) external; function transferTo(address payable dest, uint amount) external;
@ -277,7 +277,7 @@ field of a ``struct`` that is the base type of a dynamic storage array. The
:: ::
pragma solidity >=0.5.0 <0.7.0; pragma solidity >=0.5.0 <0.8.0;
contract Map { contract Map {
mapping (uint => uint)[] array; mapping (uint => uint)[] array;

View File

@ -26,7 +26,7 @@ storage.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract SimpleStorage { contract SimpleStorage {
uint storedData; // State variable uint storedData; // State variable
@ -46,7 +46,7 @@ Functions are the executable units of code within a contract.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract SimpleAuction { contract SimpleAuction {
function bid() public payable { // Function function bid() public payable { // Function
@ -74,7 +74,7 @@ Like functions, modifiers can be :ref:`overridden <modifier-overriding>`.
:: ::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract Purchase { contract Purchase {
address public seller; address public seller;
@ -101,7 +101,7 @@ Events are convenience interfaces with the EVM logging facilities.
:: ::
pragma solidity >=0.4.21 <0.7.0; pragma solidity >=0.4.21 <0.8.0;
contract SimpleAuction { contract SimpleAuction {
event HighestBidIncreased(address bidder, uint amount); // Event event HighestBidIncreased(address bidder, uint amount); // Event
@ -125,7 +125,7 @@ Structs are custom defined types that can group several variables (see
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract Ballot { contract Ballot {
struct Voter { // Struct struct Voter { // Struct
@ -146,7 +146,7 @@ Enums can be used to create custom types with a finite set of 'constant values'
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract Purchase { contract Purchase {
enum State { Created, Locked, Inactive } // Enum enum State { Created, Locked, Inactive } // Enum

View File

@ -52,7 +52,7 @@ Surround top level declarations in solidity source with two blank lines.
Yes:: Yes::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract A { contract A {
// ... // ...
@ -70,7 +70,7 @@ Yes::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract A { contract A {
// ... // ...
@ -89,7 +89,7 @@ Blank lines may be omitted between groups of related one-liners (such as stub fu
Yes:: Yes::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
abstract contract A { abstract contract A {
function spam() public virtual pure; function spam() public virtual pure;
@ -109,7 +109,7 @@ Yes::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
abstract contract A { abstract contract A {
function spam() virtual pure public; function spam() virtual pure public;
@ -243,7 +243,7 @@ Import statements should always be placed at the top of the file.
Yes:: Yes::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
import "./Owned.sol"; import "./Owned.sol";
@ -257,7 +257,7 @@ Yes::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract A { contract A {
// ... // ...
@ -290,7 +290,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last.
Yes:: Yes::
pragma solidity ^0.6.0; pragma solidity >=0.6.0 <0.8.0;
contract A { contract A {
constructor() public { constructor() public {
@ -326,7 +326,7 @@ Yes::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract A { contract A {
@ -434,7 +434,7 @@ should:
Yes:: Yes::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract Coin { contract Coin {
struct Bank { struct Bank {
@ -445,7 +445,7 @@ Yes::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract Coin contract Coin
{ {
@ -745,7 +745,7 @@ manner as modifiers if the function declaration is long or hard to read.
Yes:: Yes::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// Base contracts just to make this compile // Base contracts just to make this compile
contract B { contract B {
@ -777,7 +777,7 @@ Yes::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// Base contracts just to make this compile // Base contracts just to make this compile
@ -1000,7 +1000,7 @@ As shown in the example below, if the contract name is `Congress` and the librar
Yes:: Yes::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// Owned.sol // Owned.sol
@ -1023,7 +1023,7 @@ Yes::
and in ``Congress.sol``:: and in ``Congress.sol``::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
import "./Owned.sol"; import "./Owned.sol";
@ -1034,7 +1034,7 @@ and in ``Congress.sol``::
No:: No::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// owned.sol // owned.sol
@ -1138,7 +1138,7 @@ multiline comment starting with `/**` and ending with `*/`.
For example, the contract from `a simple smart contract <simple-smart-contract>`_ with the comments For example, the contract from `a simple smart contract <simple-smart-contract>`_ with the comments
added looks like the one below:: added looks like the one below::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
/// @author The Solidity Team /// @author The Solidity Team

View File

@ -42,7 +42,7 @@ contract that returns the value at the specified address.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract MappingExample { contract MappingExample {
mapping(address => uint) public balances; mapping(address => uint) public balances;
@ -67,7 +67,7 @@ The example below uses ``_allowances`` to record the amount someone else is allo
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract MappingExample { contract MappingExample {
@ -121,7 +121,7 @@ the ``sum`` function iterates over to sum all the values.
:: ::
pragma solidity >=0.5.99 <0.7.0; pragma solidity >=0.5.99 <0.8.0;
struct IndexValue { uint keyIndex; uint value; } struct IndexValue { uint keyIndex; uint value; }
struct KeyFlag { uint key; bool deleted; } struct KeyFlag { uint key; bool deleted; }

View File

@ -42,7 +42,7 @@ value it referred to previously.
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract DeleteExample { contract DeleteExample {
uint data; uint data;

View File

@ -57,7 +57,7 @@ Data locations are not only relevant for persistency of data, but also for the s
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract C { contract C {
// The data location of x is storage. // The data location of x is storage.
@ -161,7 +161,7 @@ or create a new memory array and copy every element.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
function f(uint len) public pure { function f(uint len) public pure {
@ -192,7 +192,7 @@ the first element to ``uint``.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract C { contract C {
function f() public pure { function f() public pure {
@ -208,7 +208,7 @@ memory arrays, i.e. the following is not possible:
:: ::
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
// This will not compile. // This will not compile.
contract C { contract C {
@ -268,7 +268,7 @@ Array Members
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract ArrayContract { contract ArrayContract {
uint[2**20] m_aLotOfIntegers; uint[2**20] m_aLotOfIntegers;
@ -400,7 +400,7 @@ Array slices are useful to ABI-decode secondary data passed in function paramete
:: ::
pragma solidity >=0.4.99 <0.7.0; pragma solidity >=0.4.99 <0.8.0;
contract Proxy { contract Proxy {
/// Address of the client contract managed by proxy i.e., this contract /// Address of the client contract managed by proxy i.e., this contract
@ -437,7 +437,7 @@ shown in the following example:
:: ::
pragma solidity >=0.4.11 <0.7.0; pragma solidity >=0.4.11 <0.8.0;
// Defines a new type with two fields. // Defines a new type with two fields.
// Declaring a struct outside of a contract allows // Declaring a struct outside of a contract allows

View File

@ -534,7 +534,7 @@ subsequent unsigned integer values starting from ``0``.
:: ::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
@ -640,7 +640,7 @@ External (or public) functions have the following members:
Example that shows how to use the members:: Example that shows how to use the members::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
contract Example { contract Example {
@ -656,7 +656,7 @@ Example that shows how to use the members::
Example that shows how to use internal function types:: Example that shows how to use internal function types::
pragma solidity >=0.4.16 <0.7.0; pragma solidity >=0.4.16 <0.8.0;
library ArrayUtils { library ArrayUtils {
@ -714,7 +714,7 @@ Example that shows how to use internal function types::
Another example that uses external function types:: Another example that uses external function types::
pragma solidity >=0.4.22 <0.7.0; pragma solidity >=0.4.22 <0.8.0;
contract Oracle { contract Oracle {

View File

@ -42,7 +42,7 @@ namespace
{ {
static char const* registrarCode = R"DELIMITER( static char const* registrarCode = R"DELIMITER(
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
abstract contract NameRegister { abstract contract NameRegister {
function addr(string memory _name) public virtual view returns (address o_owner); function addr(string memory _name) public virtual view returns (address o_owner);

View File

@ -53,7 +53,7 @@ static char const* registrarCode = R"DELIMITER(
// @authors: // @authors:
// Gav Wood <g@ethdev.com> // Gav Wood <g@ethdev.com>
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
abstract contract Registrar { abstract contract Registrar {
event Changed(string indexed name); event Changed(string indexed name);

View File

@ -56,7 +56,7 @@ static char const* walletCode = R"DELIMITER(
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the // some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
// interior is executed. // interior is executed.
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract multiowned { contract multiowned {

View File

@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(string_storage)
auto evmVersion = dev::test::Options::get().evmVersion(); auto evmVersion = dev::test::Options::get().evmVersion();
if (evmVersion <= EVMVersion::byzantium()) if (evmVersion <= EVMVersion::byzantium())
CHECK_DEPLOY_GAS(134209, 130895, evmVersion); CHECK_DEPLOY_GAS(134145, 130831, evmVersion);
// This is only correct on >=Constantinople. // This is only correct on >=Constantinople.
else if (Options::get().useABIEncoderV2) else if (Options::get().useABIEncoderV2)
{ {
@ -107,22 +107,22 @@ BOOST_AUTO_TEST_CASE(string_storage)
{ {
// Costs with 0 are cases which cannot be triggered in tests. // Costs with 0 are cases which cannot be triggered in tests.
if (evmVersion < EVMVersion::istanbul()) if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(0, 124033, evmVersion); CHECK_DEPLOY_GAS(0, 123969, evmVersion);
else else
CHECK_DEPLOY_GAS(0, 110981, evmVersion); CHECK_DEPLOY_GAS(0, 110969, evmVersion);
} }
else else
{ {
if (evmVersion < EVMVersion::istanbul()) if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(147835, 131687, evmVersion); CHECK_DEPLOY_GAS(147835, 123969, evmVersion);
else else
CHECK_DEPLOY_GAS(131871, 117231, evmVersion); CHECK_DEPLOY_GAS(131871, 110969, evmVersion);
} }
} }
else if (evmVersion < EVMVersion::istanbul()) else if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(126993, 119723, evmVersion); CHECK_DEPLOY_GAS(126929, 119659, evmVersion);
else else
CHECK_DEPLOY_GAS(114357, 107347, evmVersion); CHECK_DEPLOY_GAS(114345, 107335, evmVersion);
if (evmVersion >= EVMVersion::byzantium()) if (evmVersion >= EVMVersion::byzantium())
{ {
@ -142,9 +142,9 @@ BOOST_AUTO_TEST_CASE(string_storage)
else else
{ {
if (evmVersion < EVMVersion::istanbul()) if (evmVersion < EVMVersion::istanbul())
CHECK_GAS(21707, 21635, 20); CHECK_GAS(21707, 21559, 20);
else else
CHECK_GAS(21499, 21431, 20); CHECK_GAS(21499, 21351, 20);
} }
} }
else if (evmVersion < EVMVersion::istanbul()) else if (evmVersion < EVMVersion::istanbul())

View File

@ -14319,8 +14319,6 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name)
)"; )";
compileAndRun(sourceCode, 0, "ClientReceipt", bytes()); compileAndRun(sourceCode, 0, "ClientReceipt", bytes());
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"ClientReceipt", m_contractAddress}}); compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"ClientReceipt", m_contractAddress}});
u256 value(18);
u256 id(0x1234);
callContractFunction("f()"); callContractFunction("f()");
BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_REQUIRE_EQUAL(numLogs(), 1);

View File

@ -1,4 +1,4 @@
pragma solidity >=0.5.7 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract InvalidTest { contract InvalidTest {

View File

@ -1,4 +1,4 @@
pragma solidity >=0.4.0 <0.7.0; pragma solidity >=0.4.0 <0.8.0;
contract ERC20 { contract ERC20 {
event Transfer(address indexed from, address indexed to, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value);