Nicer error message for private payable functions

This commit is contained in:
Alex Beregszaszi 2020-07-14 14:25:17 +01:00
parent 526e7b878b
commit eab12ecf77
3 changed files with 3 additions and 3 deletions

View File

@ -337,7 +337,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
if (_function.libraryFunction())
m_errorReporter.typeError(7708_error, _function.location(), "Library functions cannot be payable.");
if (_function.isOrdinary() && !_function.isPartOfExternalInterface())
m_errorReporter.typeError(5587_error, _function.location(), "Internal functions cannot be payable.");
m_errorReporter.typeError(5587_error, _function.location(), "\"internal\" and \"private\" functions cannot be payable.");
}
auto checkArgumentAndReturnParameter = [&](VariableDeclaration const& var) {
if (type(var)->category() == Type::Category::Mapping)

View File

@ -2,4 +2,4 @@ contract test {
function f() payable internal {}
}
// ----
// TypeError 5587: (20-52): Internal functions cannot be payable.
// TypeError 5587: (20-52): "internal" and "private" functions cannot be payable.

View File

@ -2,4 +2,4 @@ contract test {
function f() payable private {}
}
// ----
// TypeError 5587: (20-51): Internal functions cannot be payable.
// TypeError 5587: (20-51): "internal" and "private" functions cannot be payable.