diff options
author | chriseth <chris@ethereum.org> | 2018-06-29 00:08:45 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-06-29 06:23:52 +0800 |
commit | eeef82b2d77c6f956039c57b0598e684254ee6dd (patch) | |
tree | 82887915936dbf242d5574c1fe9d61f5ace312d9 /docs | |
parent | 4268062985e434b00f07e3f90772b94538933b9c (diff) | |
download | dexon-solidity-eeef82b2d77c6f956039c57b0598e684254ee6dd.tar.gz dexon-solidity-eeef82b2d77c6f956039c57b0598e684254ee6dd.tar.zst dexon-solidity-eeef82b2d77c6f956039c57b0598e684254ee6dd.zip |
Fallback function has to be external: backwards-compatible changes.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 6 | ||||
-rw-r--r-- | docs/security-considerations.rst | 2 | ||||
-rw-r--r-- | docs/style-guide.rst | 14 |
3 files changed, 11 insertions, 11 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index 19eba047..5cfa7805 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -543,7 +543,7 @@ Fallback Function ================= A contract can have exactly one unnamed function. This function cannot have -arguments and cannot return anything. +arguments, cannot return anything and has to have ``external`` visibility. It is executed on a call to the contract if none of the other functions match the given function identifier (or if no data was supplied at all). @@ -591,7 +591,7 @@ Like any function, the fallback function can execute complex operations as long // Sending Ether to this contract will cause an exception, // because the fallback function does not have the `payable` // modifier. - function() public { x = 1; } + function() external { x = 1; } uint x; } @@ -599,7 +599,7 @@ Like any function, the fallback function can execute complex operations as long // This contract keeps all Ether sent to it with no way // to get it back. contract Sink { - function() public payable { } + function() external payable { } } contract Caller { diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index 52a755ca..ec67773d 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -213,7 +213,7 @@ Now someone tricks you into sending ether to the address of this attack wallet: owner = msg.sender; } - function() public { + function() external { TxUserWallet(msg.sender).transferTo(owner, msg.sender.balance); } } diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 6b28f2ab..792110e1 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -278,7 +278,7 @@ Yes:: ... } - function() public { + function() external { ... } @@ -308,6 +308,10 @@ No:: // External functions // ... + function() external { + ... + } + // Private functions // ... @@ -318,10 +322,6 @@ No:: ... } - function() public { - ... - } - // Internal functions // ... } @@ -374,13 +374,13 @@ Don't include a whitespace in the fallback function: Yes:: - function() public { + function() external { ... } No:: - function () public { + function () external { ... } |