Update documentation.

This commit is contained in:
chriseth 2018-08-07 15:10:42 +02:00
parent 683bce1869
commit e3b6c5a4bd
3 changed files with 37 additions and 38 deletions

View File

@ -5,7 +5,7 @@ How to update your code:
* Change every ``keccak256(a, b, c)`` to ``keccak256(abi.encodePacked(a, b, c))``. * Change every ``keccak256(a, b, c)`` to ``keccak256(abi.encodePacked(a, b, c))``.
* Add ``public`` to every function and ``external`` to every fallback or interface function that does not specify its visibility already. * Add ``public`` to every function and ``external`` to every fallback or interface function that does not specify its visibility already.
* Make your fallback functions ``external``. * Make your fallback functions ``external``.
* Explicitly state the storage location for local variables of struct and array types, e.g. change ``uint[] x = m_x`` to ``uint[] storage x = m_x``. * Explicitly state the data location for all variables of struct, array or mapping types (including function parameters), e.g. change ``uint[] x = m_x`` to ``uint[] storage x = m_x``. Note that ``external`` functions require parameters with a data location of ``calldata``.
* Explicitly convert values of contract type to addresses before using an ``address`` member. Example: if ``c`` is a contract, change ``c.transfer(...)`` to ``address(c).transfer(...)``. * Explicitly convert values of contract type to addresses before using an ``address`` member. Example: if ``c`` is a contract, change ``c.transfer(...)`` to ``address(c).transfer(...)``.
Breaking Changes: Breaking Changes:
@ -54,6 +54,7 @@ Breaking Changes:
* Type Checker: Disallow calling constructor with wrong argument count. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow calling constructor with wrong argument count. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Detecting cyclic dependencies in variables and structs is limited in recursion to 256. * Type Checker: Detecting cyclic dependencies in variables and structs is limited in recursion to 256.
* Type Checker: Require explicit data location for all variables, including function parameters. This was partly already the case in the experimental 0.5.0 mode.
* Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``. * Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``.
* Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode. * Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode. * Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode.
@ -61,7 +62,7 @@ Breaking Changes:
* Type Checker: Disallow "loose assembly" syntax entirely. This means that jump labels, jumps and non-functional instructions cannot be used anymore. * Type Checker: Disallow "loose assembly" syntax entirely. This means that jump labels, jumps and non-functional instructions cannot be used anymore.
* Type System: Disallow explicit and implicit conversions from decimal literals to ``bytesXX`` types. * Type System: Disallow explicit and implicit conversions from decimal literals to ``bytesXX`` types.
* Type System: Disallow explicit and implicit conversions from hex literals to ``bytesXX`` types of different size. * Type System: Disallow explicit and implicit conversions from hex literals to ``bytesXX`` types of different size.
* Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible. * Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/solidity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible.
* References Resolver: Turn missing storage locations into an error. This was already the case in the experimental 0.5.0 mode. * References Resolver: Turn missing storage locations into an error. This was already the case in the experimental 0.5.0 mode.
* Syntax Checker: Disallow functions without implementation to use modifiers. This was already the case in the experimental 0.5.0 mode. * Syntax Checker: Disallow functions without implementation to use modifiers. This was already the case in the experimental 0.5.0 mode.
* Syntax Checker: Named return values in function types are an error. * Syntax Checker: Named return values in function types are an error.

View File

@ -801,7 +801,7 @@ The full contract
constructor() public payable {} constructor() public payable {}
function claimPayment(uint256 amount, uint256 nonce, bytes signature) public { function claimPayment(uint256 amount, uint256 nonce, bytes memory signature) public {
require(!usedNonces[nonce]); require(!usedNonces[nonce]);
usedNonces[nonce] = true; usedNonces[nonce] = true;
@ -820,7 +820,7 @@ The full contract
} }
/// signature methods. /// signature methods.
function splitSignature(bytes sig) function splitSignature(bytes memory sig)
internal internal
pure pure
returns (uint8 v, bytes32 r, bytes32 s) returns (uint8 v, bytes32 r, bytes32 s)
@ -839,7 +839,7 @@ The full contract
return (v, r, s); return (v, r, s);
} }
function recoverSigner(bytes32 message, bytes sig) function recoverSigner(bytes32 message, bytes memory sig)
internal internal
pure pure
returns (address) returns (address)
@ -1003,7 +1003,7 @@ The full contract
expiration = now + duration; expiration = now + duration;
} }
function isValidSignature(uint256 amount, bytes signature) function isValidSignature(uint256 amount, bytes memory signature)
internal internal
view view
returns (bool) returns (bool)
@ -1017,7 +1017,7 @@ The full contract
/// the recipient can close the channel at any time by presenting a /// the recipient can close the channel at any time by presenting a
/// signed amount from the sender. the recipient will be sent that amount, /// signed amount from the sender. the recipient will be sent that amount,
/// and the remainder will go back to the sender /// and the remainder will go back to the sender
function close(uint256 amount, bytes signature) public { function close(uint256 amount, bytes memory signature) public {
require(msg.sender == recipient); require(msg.sender == recipient);
require(isValidSignature(amount, signature)); require(isValidSignature(amount, signature));
@ -1043,7 +1043,7 @@ The full contract
/// All functions below this are just taken from the chapter /// All functions below this are just taken from the chapter
/// 'creating and verifying signatures' chapter. /// 'creating and verifying signatures' chapter.
function splitSignature(bytes sig) function splitSignature(bytes memory sig)
internal internal
pure pure
returns (uint8 v, bytes32 r, bytes32 s) returns (uint8 v, bytes32 r, bytes32 s)
@ -1062,7 +1062,7 @@ The full contract
return (v, r, s); return (v, r, s);
} }
function recoverSigner(bytes32 message, bytes sig) function recoverSigner(bytes32 message, bytes memory sig)
internal internal
pure pure
returns (address) returns (address)

View File

@ -580,16 +580,18 @@ variables are held).
Data location Data location
------------- -------------
Every complex type, i.e. *arrays* and *structs*, has an additional
annotation, the "data location", about whether it is stored in memory or in storage. Depending on the
context, there is always a default, but it can be overridden by appending
either ``storage`` or ``memory`` to the type. The default for function parameters (including return parameters) is ``memory``, the default for local variables is ``storage`` and the location is forced
to ``storage`` for state variables (obviously).
There is also a third data location, ``calldata``, which is a non-modifiable, Every complex type, i.e. *arrays* and *structs*, has an additional
non-persistent area where function arguments are stored. Function parameters annotation, the "data location", about where it is stored. There are three data locations:
(not return parameters) of external functions are forced to ``calldata`` and ``memory``, ``storage`` and ``calldata``. Calldata is only valid for parameters of external contract
behave mostly like ``memory``. functions and is required for this type of parameter. Calldata is a non-modifiable,
non-persistent area where function arguments are stored, and behaves mostly like memory.
.. note::
Prior to version 0.5.0 the data location could be omitted, and would default to different locations
depending on the kind of variable, function type, etc., but all complex types must now give an explicit
data location.
Data locations are important because they change how assignments behave: Data locations are important because they change how assignments behave:
assignments between storage and memory and also to a state variable (even from other state variables) assignments between storage and memory and also to a state variable (even from other state variables)
@ -635,10 +637,6 @@ Forced data location:
- parameters (not return) of external functions: calldata - parameters (not return) of external functions: calldata
- state variables: storage - state variables: storage
Default data location:
- parameters (also return) of functions: memory
- all other local variables: storage
.. index:: ! array .. index:: ! array
.. _arrays: .. _arrays: