aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorChris Ward <chriswhward@gmail.com>2018-10-19 18:59:21 +0800
committerchriseth <chris@ethereum.org>2018-11-27 03:07:22 +0800
commitae542176e3a8490cb83a42a309208fa6c5fd1589 (patch)
tree858eb4de709968c18b61f10463941dbab36481dc /docs
parent2f0088f620e88c06387b69d00a2f91f5303cfe1f (diff)
downloaddexon-solidity-ae542176e3a8490cb83a42a309208fa6c5fd1589.tar.gz
dexon-solidity-ae542176e3a8490cb83a42a309208fa6c5fd1589.tar.zst
dexon-solidity-ae542176e3a8490cb83a42a309208fa6c5fd1589.zip
Add that pure functions can use revert and require
Diffstat (limited to 'docs')
-rw-r--r--docs/contracts.rst23
1 files changed, 16 insertions, 7 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index c1c51e56..68c7bea3 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -569,6 +569,20 @@ In addition to the list of state modifying statements explained above, the follo
}
}
+Pure functions are able to use the `revert()` and `require()` functions to revert
+potential state changes when an :ref:`error occurs <assert-and-require>`.
+
+Reverting a state change is not considered a "state modification", as only changes to the
+state made previously in code that did not have the ``view`` or ``pure`` restriction
+are reverted and that code has the option to catch the ``revert`` and not pass it on.
+
+This behaviour is also in line with the ``STATICCALL`` opcode.
+
+.. warning::
+ It is not possible to prevent functions from reading the state at the level
+ of the EVM, it is only possible to prevent them from writing to the state
+ (i.e. only ``view`` can be enforced at the EVM level, ``pure`` can not).
+
.. note::
Prior to version 0.5.0, the compiler did not use the ``STATICCALL`` opcode
for ``pure`` functions.
@@ -577,13 +591,8 @@ In addition to the list of state modifying statements explained above, the follo
By using ``STATICCALL`` for ``pure`` functions, modifications to the
state are prevented on the level of the EVM.
-.. warning::
- It is not possible to prevent functions from reading the state at the level
- of the EVM, it is only possible to prevent them from writing to the state
- (i.e. only ``view`` can be enforced at the EVM level, ``pure`` can not).
-
-.. warning::
- Before version 0.4.17 the compiler did not enforce that ``pure`` is not reading the state.
+.. note::
+ Prior to version 0.4.17 the compiler did not enforce that ``pure`` is not reading the state.
It is a compile-time type check, which can be circumvented doing invalid explicit conversions
between contract types, because the compiler can verify that the type of the contract does
not do state-changing operations, but it cannot check that the contract that will be called