Issue error for callvalue in nonpayable function

This commit is contained in:
Leonardo Alt
2019-03-19 20:45:27 +01:00
parent 11198cd76a
commit 9acec99c31
11 changed files with 73 additions and 6 deletions
+5 -3
View File
@@ -112,6 +112,8 @@ private:
{
if (eth::SemanticInformation::invalidInViewFunctions(_instruction))
m_reportMutability(StateMutability::NonPayable, _location);
else if (_instruction == Instruction::CALLVALUE)
m_reportMutability(StateMutability::Payable, _location);
else if (eth::SemanticInformation::invalidInPureFunctions(_instruction))
m_reportMutability(StateMutability::View, _location);
}
@@ -270,13 +272,13 @@ void ViewPureChecker::reportMutability(
if (_nestedLocation)
m_errorReporter.typeError(
_location,
SecondarySourceLocation().append("\"msg.value\" appears here inside the modifier.", *_nestedLocation),
"This modifier uses \"msg.value\" and thus the function has to be payable or internal."
SecondarySourceLocation().append("\"msg.value\" or \"callvalue()\" appear here inside the modifier.", *_nestedLocation),
"This modifier uses \"msg.value\" or \"callvalue()\" and thus the function has to be payable or internal."
);
else
m_errorReporter.typeError(
_location,
"\"msg.value\" can only be used in payable public functions. Make the function "
"\"msg.value\" and \"callvalue()\" can only be used in payable public functions. Make the function "
"\"payable\" or use an internal function to avoid this error."
);
m_errors = true;