Merge pull request #7888 from fulldecent/patch-16

Clarify new fallback function introduction
This commit is contained in:
chriseth 2019-12-04 10:34:38 +01:00 committed by GitHub
commit d41d042d81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,12 +61,16 @@ This section highlights changes that affect syntax and semantics.
* The unnamed function commonly referred to as "fallback function" was split up into a new
fallback function that is defined using the ``fallback`` keyword and a receive ether function
defined using the ``receive`` keyword. If present, the receive ether function is called
whenever the call data is empty. The new fallback function is called when no
other function matches. It can be payable in which case it may accept value
or non-payable in which case transactions not matching any other function
which send value will revert. If you only implement the receive and not the fallback function, calling a non-existing function on your contract will now revert. You should only need to implement the fallback function
if you are following an upgrade or proxy pattern.
defined using the ``receive`` keyword.
* If present, the receive ether function is called whenever the call data is empty (whether
or not ether is received). This function is implicitly ``payable``.
* The new fallback function is called when no other function matches (if the receive ether
function does not exist then this includes calls with empty call data).
You can make this function ``payable`` or not. If it is not ``payable`` then transactions
not matching any other function which send value will revert. You should only need to
implement the new fallback function if you are following an upgrade or proxy pattern.
* Functions can now only be overridden when they are either marked with the ``virtual`` keyword or defined in an interface. When overriding a function or modifier, the new keyword ``override`` must be used. When overriding a function or modifier defined in multiple parallel bases, all bases must be listed in parentheses after the keyword like so: ``override(Base1, Base2)``.