Merge pull request #13613 from Andy53/patch-1

Clarification to the documentation on converting payable to non payable functions.
This commit is contained in:
matheusaaguiar 2022-11-10 16:28:36 -03:00 committed by GitHub
commit c72645327e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -770,6 +770,16 @@ 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.
To clarify, rejecting ether is more restrictive than not rejecting ether.
This means you can override a payable function with a non-payable but not the
other way around.
Additionally, When you define a ``non-payable`` function pointer,
the compiler does not enforce that the pointed function will actually reject ether.
Instead, it enforces that the function pointer is never used to send ether.
Which makes it possible to assign a ``payable`` function pointer to a ``non-payable``
function pointer ensuring both types behave the same way, i.e, both cannot be used
to send ether.
If a function type variable is not initialised, calling it results
in a :ref:`Panic error<assert-and-require>`. The same happens if you call a function after using ``delete``