Skip to content

Commit c726453

Browse files
Merge pull request ethereum#13613 from Andy53/patch-1
Clarification to the documentation on converting payable to non payable functions.
2 parents 1bd35b1 + 1e5c229 commit c726453

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/types/value-types.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,16 @@ confusing, but in essence, if a function is ``payable``, this means that it
770770
also accepts a payment of zero Ether, so it also is ``non-payable``.
771771
On the other hand, a ``non-payable`` function will reject Ether sent to it,
772772
so ``non-payable`` functions cannot be converted to ``payable`` functions.
773+
To clarify, rejecting ether is more restrictive than not rejecting ether.
774+
This means you can override a payable function with a non-payable but not the
775+
other way around.
776+
777+
Additionally, When you define a ``non-payable`` function pointer,
778+
the compiler does not enforce that the pointed function will actually reject ether.
779+
Instead, it enforces that the function pointer is never used to send ether.
780+
Which makes it possible to assign a ``payable`` function pointer to a ``non-payable``
781+
function pointer ensuring both types behave the same way, i.e, both cannot be used
782+
to send ether.
773783

774784
If a function type variable is not initialised, calling it results
775785
in a :ref:`Panic error<assert-and-require>`. The same happens if you call a function after using ``delete``

0 commit comments

Comments
 (0)