From 87241fd58c7ddf45224f308f5fa10d88030bdb25 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 28 Jun 2018 18:09:16 +0200 Subject: Fallback function has to be external. --- libsolidity/analysis/TypeChecker.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 3bd0b4c1..ebf523ea 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\"."); } -- cgit From 2211739fc4548c70be887d6666430a25b66a3bb8 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 28 Jun 2018 18:09:27 +0200 Subject: Update tests. --- test/libsolidity/syntaxTests/fallback/default_visibility.sol | 2 +- test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol | 4 ++-- .../syntaxTests/inlineAssembly/storage_reference_fine.sol | 2 +- .../nameAndTypeResolution/526_fallback_marked_external_v050.sol | 4 ---- .../nameAndTypeResolution/527_fallback_marked_internal.sol | 1 + .../nameAndTypeResolution/527_fallback_marked_internal_v050.sol | 6 ------ .../nameAndTypeResolution/528_fallback_marked_private.sol | 1 + .../nameAndTypeResolution/528_fallback_marked_private_v050.sol | 6 ------ .../nameAndTypeResolution/529_fallback_marked_public.sol | 1 + .../nameAndTypeResolution/529_fallback_marked_public_v050.sol | 6 ------ 10 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol 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". -- cgit From bc6b42a9f6056f9e6e3bf9467562fd61c044e95b Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 28 Jun 2018 22:35:18 +0200 Subject: Changelog entry. --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index b36bec2e..9b79af4f 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: @@ -32,6 +33,7 @@ Breaking Changes: * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size. * 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: 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. -- cgit