aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp2
-rw-r--r--libsolidity/interface/CompilerStack.cpp14
-rw-r--r--libsolidity/interface/CompilerStack.h4
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol5
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol3
7 files changed, 20 insertions, 14 deletions
diff --git a/Changelog.md b/Changelog.md
index c0fd4193..07b74ddc 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -22,6 +22,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 f234dcaf..c408b393 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/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 47dc30cf..a8668336 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -669,7 +669,7 @@ void CompilerStack::resolveImports()
swap(m_sourceOrder, sourceOrder);
}
-string CompilerStack::absolutePath(string const& _path, string const& _reference) const
+string CompilerStack::absolutePath(string const& _path, string const& _reference)
{
using path = boost::filesystem::path;
path p(_path);
@@ -711,9 +711,15 @@ void CompilerStack::compileContract(
for (auto const* dependency: _contract.annotation().contractDependencies)
compileContract(*dependency, _compiledContracts);
- shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimize, m_optimizeRuns);
Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
+
+ shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimize, m_optimizeRuns);
+ compiledContract.compiler = compiler;
+
string metadata = createMetadata(compiledContract);
+ compiledContract.metadata = metadata;
+
+ // Prepare CBOR metadata for the bytecode
bytes cborEncodedHash =
// CBOR-encoding of the key "bzzr0"
bytes{0x65, 'b', 'z', 'z', 'r', '0'}+
@@ -734,8 +740,9 @@ void CompilerStack::compileContract(
solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large");
// 16-bit big endian length
cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
+
+ // Run optimiser and compile the contract.
compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
- compiledContract.compiler = compiler;
try
{
@@ -763,7 +770,6 @@ void CompilerStack::compileContract(
solAssert(false, "Assembly exception for deployed bytecode");
}
- compiledContract.metadata = metadata;
_compiledContracts[compiledContract.contract] = &compiler->assembly();
try
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index 13c9cc7a..018c61ec 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -273,9 +273,9 @@ private:
std::string applyRemapping(std::string const& _path, std::string const& _context);
void resolveImports();
/// @returns the absolute path corresponding to @a _path relative to @a _reference.
- std::string absolutePath(std::string const& _path, std::string const& _reference) const;
+ static std::string absolutePath(std::string const& _path, std::string const& _reference);
/// Helper function to return path converted strings.
- std::string sanitizePath(std::string const& _path) const { return boost::filesystem::path(_path).generic_string(); }
+ static std::string sanitizePath(std::string const& _path) { return boost::filesystem::path(_path).generic_string(); }
/// @returns true if the contract is requested to be compiled.
bool isRequestedContract(ContractDefinition const& _contract) const;
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 00000000..12191530
--- /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 67a74e54..00000000
--- 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 d3c84678..c7703b47 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.