From f49238068861517fe4b520fd9fc78acf58894ca2 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Wed, 12 Oct 2016 10:57:35 +0200 Subject: Mention `payable` in the description when Solidity throws --- docs/control-structures.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/control-structures.rst b/docs/control-structures.rst index fa983d87..56c422e9 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -327,11 +327,12 @@ Currently, there are six situations, where exceptions happen automatically in So 1. If you access an array on a too large or negative index (i.e. ``x[i]`` where ``i >= x.length`` or ``i < 0``). 2. If you access a fixed-length ``bytes`` on a too large or negative index. 3. If a function called via a message call does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself), except when a low level operation ``call``, ``send``, ``delegatecall`` or ``callcode`` is used. -4. If a non-existent function on a library is called or Ether is sent to a library. +4. If a non-existent function on a library is called 5. If you divide or modulo by zero (e.g. ``5 / 0`` or ``23 % 0``). 6. If you perform an external function call targeting a contract that contains no code. 7. If a contract-creation call using the ``new`` keyword does not finish properly. 8. If a contract is called but there are no matching interface or fallback function. +9. If Ether is sent to a contract interface function without ``payable`` modifier (including the constructor and the fallback function) Internally, Solidity performs an "invalid jump" when an exception is thrown and thus causes the EVM to revert all changes made to the state. The reason for this is that there is no safe way to continue execution, because an expected effect did not occur. Because we want to retain the atomicity of transactions, the safest thing to do is to revert all changes and make the whole transaction (or at least call) without effect. -- cgit v1.2.3