From dbfee87860187e3f3d5b6c06fffe0e601d01d7ea Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 14 Jun 2018 17:32:09 +0200 Subject: [PATCH] Return parameters in function types may not be named. --- Changelog.md | 1 + libsolidity/analysis/SyntaxChecker.cpp | 2 +- .../function_type_return_parameters_with_names.sol | 5 +++++ .../warn_function_type_return_parameters_with_names.sol | 5 ----- .../syntaxTests/parsing/function_type_in_struct.sol | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol delete mode 100644 test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol diff --git a/Changelog.md b/Changelog.md index 4389fbd94..b05dad4f2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,7 @@ Breaking Changes: * Type Checker: Disallow arithmetic operations for boolean variables. * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size. * 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. Language Features: * General: Allow appending ``calldata`` keyword to types, to explicitly specify data location for arguments of external functions. diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index f234dcaff..c408b393e 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -255,7 +255,7 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node) for (auto const& decl: _node.returnParameterTypeList()->parameters()) if (!decl->name().empty()) - m_errorReporter.warning(decl->location(), "Naming function type return parameters is deprecated."); + m_errorReporter.syntaxError(decl->location(), "Return parameters in function types may not be named."); return true; } diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol new file mode 100644 index 000000000..121915300 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol @@ -0,0 +1,5 @@ +contract C { + function(uint) returns (bool ret) f; +} +// ---- +// SyntaxError: (41-49): Return parameters in function types may not be named. diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol deleted file mode 100644 index 67a74e546..000000000 --- a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - function(uint) returns (bool ret) f; -} -// ---- -// Warning: (41-49): Naming function type return parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol index d3c84678e..c7703b47c 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol @@ -1,6 +1,6 @@ contract test { struct S { - function (uint x, uint y) internal returns (uint a) f; + function (uint x, uint y) internal returns (uint) f; function (uint, uint) external returns (uint) g; uint d; } @@ -8,4 +8,3 @@ contract test { // ---- // Warning: (49-55): Naming function type parameters is deprecated. // Warning: (57-63): Naming function type parameters is deprecated. -// Warning: (83-89): Naming function type return parameters is deprecated.