Merge pull request #4740 from ethereum/enforceNumberOfReturnValues

Disallow empty return in function with return arguments.
This commit is contained in:
chriseth
2018-08-08 14:59:09 +02:00
committed by GitHub
13 changed files with 102 additions and 39 deletions
+6 -2
View File
@@ -982,9 +982,13 @@ bool TypeChecker::visit(ForStatement const& _forStatement)
void TypeChecker::endVisit(Return const& _return)
{
if (!_return.expression())
return;
ParameterList const* params = _return.annotation().functionReturnParameters;
if (!_return.expression())
{
if (params && !params->parameters().empty())
m_errorReporter.typeError(_return.location(), "Return arguments required.");
return;
}
if (!params)
{
m_errorReporter.typeError(_return.location(), "Return arguments not allowed.");