mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4376 from ethereum/fallbackExternal
Fallback functions have to be external
This commit is contained in:
commit
d84976dc87
@ -3,6 +3,7 @@
|
||||
How to update your code:
|
||||
* Change every ``.call()`` to a ``.call("")`` and every ``.call(signature, a, b, c)`` to use ``.call(abi.encodeWithSignature(signature, a, b, c))`` (the last one only works for value types).
|
||||
* Change every ``keccak256(a, b, c)`` to ``keccak256(abi.encodePacked(a, b, c))``.
|
||||
* Make your fallback functions ``external``.
|
||||
|
||||
|
||||
Breaking Changes:
|
||||
@ -37,6 +38,7 @@ Breaking Changes:
|
||||
* Type Checker: Disallow specifying base constructor arguments multiple times in the same inheritance hierarchy. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``.
|
||||
* Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
|
||||
* Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible.
|
||||
* Syntax Checker: Named return values in function types are an error.
|
||||
* Syntax Checker: Disallow unary ``+``. This was already the case in the experimental 0.5.0 mode.
|
||||
|
@ -123,10 +123,7 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
|
||||
m_errorReporter.typeError(function->parameterList().location(), "Fallback function cannot take parameters.");
|
||||
if (!function->returnParameters().empty())
|
||||
m_errorReporter.typeError(function->returnParameterList()->location(), "Fallback function cannot return values.");
|
||||
if (
|
||||
_contract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050) &&
|
||||
function->visibility() != FunctionDefinition::Visibility::External
|
||||
)
|
||||
if (function->visibility() != FunctionDefinition::Visibility::External)
|
||||
m_errorReporter.typeError(function->location(), "Fallback function must be defined as \"external\".");
|
||||
}
|
||||
|
||||
|
@ -3,4 +3,4 @@ contract C {
|
||||
function() {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (90-103): No visibility specified. Defaulting to "public".
|
||||
// TypeError: (90-103): Fallback function must be defined as "external".
|
||||
|
@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
uint[] x;
|
||||
function() public {
|
||||
function() external {
|
||||
uint[] storage y = x;
|
||||
assembly {
|
||||
pop(y)
|
||||
@ -8,4 +8,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (117-118): You have to use the _slot or _offset suffix to access storage reference variables.
|
||||
// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables.
|
||||
|
@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
uint[] x;
|
||||
function() public {
|
||||
function() external {
|
||||
uint[] storage y = x;
|
||||
assembly {
|
||||
pop(y_slot)
|
||||
|
@ -1,4 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function () external { }
|
||||
}
|
@ -2,3 +2,4 @@ contract C {
|
||||
function () internal { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (17-41): Fallback function must be defined as "external".
|
||||
|
@ -1,6 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function () internal { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (47-71): Fallback function must be defined as "external".
|
@ -2,3 +2,4 @@ contract C {
|
||||
function () private { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (17-40): Fallback function must be defined as "external".
|
||||
|
@ -1,6 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function () private { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (47-70): Fallback function must be defined as "external".
|
@ -2,3 +2,4 @@ contract C {
|
||||
function () public { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (17-39): Fallback function must be defined as "external".
|
||||
|
@ -1,6 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function () public { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (47-69): Fallback function must be defined as "external".
|
Loading…
Reference in New Issue
Block a user