diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-08 02:47:23 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-08 02:48:07 +0800 |
commit | cc83e69469ed3968d840effb340e925aceeb64fa (patch) | |
tree | f510fa5354539ae1313d06511cecdcb2bddf54e7 | |
parent | d7756322c07634fa2ca0649a33585fc167079786 (diff) | |
download | dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.tar dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.tar.gz dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.tar.bz2 dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.tar.lz dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.tar.xz dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.tar.zst dexon-solidity-cc83e69469ed3968d840effb340e925aceeb64fa.zip |
Disallow empty return expressions in functions with non-empty return parameters.
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index 0790c0ca..17cad802 100644 --- a/Changelog.md +++ b/Changelog.md @@ -46,6 +46,7 @@ Breaking Changes: * Type Checker: Disallow calling base constructors without parentheses. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size. * Type Checker: Disallow conversions between unrelated contract types. Explicit conversion via ``address`` can still achieve it. + * Type Checker: Disallow empty return statements for functions with one or more return values. * Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode. * Type Checker: Disallow multi-variable declarations with mismatching number of values. This was already the case in the experimental 0.5.0 mode. * 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. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 38331a43..0e87053e 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -979,9 +979,13 @@ bool TypeChecker::visit(ForStatement const& _forStatement) void TypeChecker::endVisit(Return const& _return) { + ParameterList const* params = _return.annotation().functionReturnParameters; if (!_return.expression()) + { + if (params && !params->parameters().empty()) + m_errorReporter.typeError(_return.location(), "Return arguments required."); return; - ParameterList const* params = _return.annotation().functionReturnParameters; + } if (!params) { m_errorReporter.typeError(_return.location(), "Return arguments not allowed."); |