aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorJesse Busman <jesse@jesbus.com>2018-06-28 19:31:23 +0800
committerchriseth <chris@ethereum.org>2018-08-14 23:13:10 +0800
commitc05911914550388d7a28563096e3b9772f1b9d23 (patch)
tree6f37883664d07813d82810cbc4592beb0b47a16b /docs
parent414559bd0746424484d8fd1111cd9ee440eb5306 (diff)
downloaddexon-solidity-c05911914550388d7a28563096e3b9772f1b9d23.tar.gz
dexon-solidity-c05911914550388d7a28563096e3b9772f1b9d23.tar.zst
dexon-solidity-c05911914550388d7a28563096e3b9772f1b9d23.zip
Add implicit convertibility to function pointer with higher state mutability
Diffstat (limited to 'docs')
-rw-r--r--docs/types.rst22
1 files changed, 20 insertions, 2 deletions
diff --git a/docs/types.rst b/docs/types.rst
index c216fd83..251f1edd 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -426,8 +426,26 @@ function type should not return anything, the whole ``returns (<return types>)``
part has to be omitted.
By default, function types are internal, so the ``internal`` keyword can be
-omitted. In contrast, contract functions themselves are public by default,
-only when used as the name of a type, the default is internal.
+omitted. Note that this only applies to function types. Visibility has
+to be specified explicitly for functions defined in contracts, they
+do not have a default.
+
+A function type ``A`` is implicitly convertible to a function type ``B`` if and only if
+their parameter types are identical, their return types are identical,
+their internal/external property is identical and the state mutability of ``A``
+is not more restrictive than the state mutability of ``B``. In particular:
+
+ - ``pure`` functions can be converted to ``view`` and ``non-payable`` functions
+ - ``view`` functions can be converted to ``non-payable`` functions
+ - ``payable`` functions can be converted to ``non-payable`` functions
+
+No other conversions are possible.
+
+The rule about ``payable`` and ``non-payable`` might be a little
+confusing, but in essence, if a function is ``payable``, this means that it
+also accepts a payment of zero Ether, so it also is ``non-payable``.
+On the other hand, a ``non-payable`` function will reject Ether sent to it,
+so ``non-payable`` functions cannot be converted to ``payable`` functions.
If a function type variable is not initialized, calling it will result
in an exception. The same happens if you call a function after using ``delete``