mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fallback function has to be external: backwards-compatible changes.
This commit is contained in:
+3
-3
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user