diff options
author | chriseth <chris@ethereum.org> | 2018-07-11 03:39:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-11 03:39:25 +0800 |
commit | d84976dc871a1fdfab233650b989af69e325bf2b (patch) | |
tree | 146c0efc9c43d26617993cf5e8fc1e5cc592def6 | |
parent | 49cc1b855464d428f022267b5997dfc093ea1b44 (diff) | |
parent | bc6b42a9f6056f9e6e3bf9467562fd61c044e95b (diff) | |
download | dexon-solidity-d84976dc871a1fdfab233650b989af69e325bf2b.tar.gz dexon-solidity-d84976dc871a1fdfab233650b989af69e325bf2b.tar.zst dexon-solidity-d84976dc871a1fdfab233650b989af69e325bf2b.zip |
Merge pull request #4376 from ethereum/fallbackExternal
Fallback functions have to be external
12 files changed, 10 insertions, 30 deletions
diff --git a/Changelog.md b/Changelog.md index 65032511..bdbf85fb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index b631bd1e..78536664 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -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\"."); } diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol index f45bbd3c..31123d59 100644 --- a/test/libsolidity/syntaxTests/fallback/default_visibility.sol +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -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". diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index 55c83674..b6dd12b8 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index 3ae24b34..84f98ed9 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() public { + function() external { uint[] storage y = x; assembly { pop(y_slot) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol deleted file mode 100644 index f13a87ec..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol +++ /dev/null @@ -1,4 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () external { } -} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol index 2d425037..b8e1c654 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol @@ -2,3 +2,4 @@ contract C { function () internal { } } // ---- +// TypeError: (17-41): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol deleted file mode 100644 index 6c8b23c8..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () internal { } -} -// ---- -// TypeError: (47-71): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol index 2105c815..6038a99f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol @@ -2,3 +2,4 @@ contract C { function () private { } } // ---- +// TypeError: (17-40): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol deleted file mode 100644 index be381909..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () private { } -} -// ---- -// TypeError: (47-70): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol index 42585137..d9c1580f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol @@ -2,3 +2,4 @@ contract C { function () public { } } // ---- +// TypeError: (17-39): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol deleted file mode 100644 index d0beffda..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () public { } -} -// ---- -// TypeError: (47-69): Fallback function must be defined as "external". |