aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/contracts.rst17
-rw-r--r--docs/control-structures.rst12
-rw-r--r--docs/installing-solidity.rst2
-rw-r--r--docs/solidity-by-example.rst2
-rw-r--r--docs/units-and-global-variables.rst4
5 files changed, 20 insertions, 17 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 862ec54d..fa6df6bf 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -406,7 +406,7 @@ Constant State Variables
State variables can be declared as ``constant``. In this case, they have to be
assigned from an expression which is a constant at compile time. Any expression
-that accesses storage, blockchain data (e.g. ``now``, ``this.balance`` or
+that accesses storage, blockchain data (e.g. ``now``, ``address(this).balance`` or
``block.number``) or
execution data (``msg.value`` or ``gasleft()``) or make calls to external contracts are disallowed. Expressions
that might have a side-effect on memory allocation are allowed, but those that
@@ -505,7 +505,7 @@ Functions can be declared ``pure`` in which case they promise not to read from o
In addition to the list of state modifying statements explained above, the following are considered reading from the state:
#. Reading from state variables.
-#. Accessing ``this.balance`` or ``<address>.balance``.
+#. Accessing ``address(this).balance`` or ``<address>.balance``.
#. Accessing any of the members of ``block``, ``tx``, ``msg`` (with the exception of ``msg.sig`` and ``msg.data``).
#. Calling any function not marked ``pure``.
#. Using inline assembly that contains certain opcodes.
@@ -580,7 +580,7 @@ Like any function, the fallback function can execute complex operations as long
but do not define a fallback function
throw an exception, sending back the Ether (this was different
before Solidity v0.4.0). So if you want your contract to receive Ether,
- you have to implement a fallback function.
+ you have to implement a payable fallback function.
.. warning::
A contract without a payable fallback function can receive Ether as a recipient of a `coinbase transaction` (aka `miner block reward`)
@@ -588,11 +588,11 @@ Like any function, the fallback function can execute complex operations as long
A contract cannot react to such Ether transfers and thus also cannot reject them. This is a design choice of the EVM and Solidity cannot work around it.
- It also means that ``this.balance`` can be higher than the sum of some manual accounting implemented in a contract (i.e. having a counter updated in the fallback function).
+ It also means that ``address(this).balance`` can be higher than the sum of some manual accounting implemented in a contract (i.e. having a counter updated in the fallback function).
::
- pragma solidity ^0.4.0;
+ pragma solidity >0.4.24;
contract Test {
// This function is called for all messages sent to
@@ -613,14 +613,13 @@ Like any function, the fallback function can execute complex operations as long
contract Caller {
function callTest(Test test) public {
- test.call(abi.encodeWithSignature("nonExistingFunction()"));
+ address(test).call(abi.encodeWithSignature("nonExistingFunction()"));
// results in test.x becoming == 1.
- // The following will not compile, but even
- // if someone sends ether to that contract,
+ // If someone sends ether to that contract,
// the transaction will fail and reject the
// Ether.
- //test.send(2 ether);
+ address(test).send(2 ether);
}
}
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 50c401e2..ead236c4 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -297,9 +297,9 @@ These can then either be assigned to newly declared variables or to pre-existing
}
.. note::
- Prior to version 0.4.24 it was possible to assign to tuples of smaller size, either
+ Prior to version 0.5.0 it was possible to assign to tuples of smaller size, either
filling up on the left or on the right side (which ever was empty). This is
- now deprecated, both sides have to have the same number of components.
+ now disallowed, so both sides have to have the same number of components.
Complications for Arrays and Structs
------------------------------------
@@ -418,18 +418,18 @@ a message string for ``require``, but not for ``assert``.
::
- pragma solidity ^0.4.22;
+ pragma solidity >0.4.24;
contract Sharer {
function sendHalf(address addr) public payable returns (uint balance) {
require(msg.value % 2 == 0, "Even value required.");
- uint balanceBeforeTransfer = this.balance;
+ uint balanceBeforeTransfer = address(this).balance;
addr.transfer(msg.value / 2);
// Since transfer throws an exception on failure and
// cannot call back here, there should be no way for us to
// still have half of the money.
- assert(this.balance == balanceBeforeTransfer - msg.value / 2);
- return this.balance;
+ assert(address(this).balance == balanceBeforeTransfer - msg.value / 2);
+ return address(this).balance;
}
}
diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst
index 05ee0748..5b3fdf87 100644
--- a/docs/installing-solidity.rst
+++ b/docs/installing-solidity.rst
@@ -64,7 +64,7 @@ repository contains potentially unstable changes in the develop branch.
.. code:: bash
- docker run ethereum/solc:stable solc --version
+ docker run ethereum/solc:stable --version
Currently, the docker image only contains the compiler executable,
so you have to do some additional work to link in the source and
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index b1985426..cd281aad 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -1035,7 +1035,7 @@ The full contract
/// if the timeout is reached without the recipient closing the channel,
/// then the Ether is released back to the sender.
- function clainTimeout() public {
+ function claimTimeout() public {
require(now >= expiration);
selfdestruct(sender);
}
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index 61ae51a8..b24b8b71 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -181,6 +181,10 @@ For more information, see the section on :ref:`address`.
Use a pattern where the recipient withdraws the money.
.. note::
+ Prior to version 0.5.0, Solidity allowed address members to be accessed by a contract instance, for example ``this.balance``.
+ This is now forbidden and an explicit conversion to address must be done: ``address(this).balance``.
+
+.. note::
If storage variables are accessed via a low-level delegatecall, the storage layout of the two contracts
must align in order for the called contract to correctly access the storage variables of the calling contract by name.
This is of course not the case if storage pointers are passed as function arguments as in the case for