diff options
author | chriseth <chris@ethereum.org> | 2016-11-14 20:32:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 20:32:38 +0800 |
commit | 9383a18c57d0f39bec00b32392bddda81309ae14 (patch) | |
tree | 4030152469d7dd99aa2a3e4b00b9406e6786e8d7 /docs | |
parent | 4f546e6563fee688d79b37b8c68a270c380cb3e2 (diff) | |
parent | 81f5734cbe029b93aa143e5eb7f57869ab63af7b (diff) | |
download | dexon-solidity-9383a18c57d0f39bec00b32392bddda81309ae14.tar.gz dexon-solidity-9383a18c57d0f39bec00b32392bddda81309ae14.tar.zst dexon-solidity-9383a18c57d0f39bec00b32392bddda81309ae14.zip |
Merge pull request #1334 from ethereum/enum_conversion
check enum value range during conversion
Diffstat (limited to 'docs')
-rw-r--r-- | docs/control-structures.rst | 7 | ||||
-rw-r--r-- | docs/types.rst | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 51f43015..bbb90e6a 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -329,9 +329,10 @@ Currently, there are situations, where exceptions happen automatically in Solidi 3. If you call a function via a message call but it 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. The low level operations never throw exceptions but indicate failures by returning ``false``. 4. If you create a contract using the ``new`` keyword but the contract creation does not finish properly (see above for the definition of "not finish properly"). 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 your contract receives Ether via a public function without ``payable`` modifier (including the constructor and the fallback function). -8. If your contract receives Ether via a public accessor function. +6. If you convert a value too big or negative into an enum type. +7. If you perform an external function call targeting a contract that contains no code. +8. If your contract receives Ether via a public function without ``payable`` modifier (including the constructor and the fallback function). +9. If your contract receives Ether via a public accessor 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. diff --git a/docs/types.rst b/docs/types.rst index 9e7d9b4a..9ec9e526 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -237,7 +237,8 @@ Enums ===== Enums are one way to create a user-defined type in Solidity. They are explicitly convertible -to and from all integer types but implicit conversion is not allowed. +to and from all integer types but implicit conversion is not allowed. The explicit conversions +check the value ranges at runtime and a failure causes an exception. Enums needs at least one member. :: |