mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Issue error for callvalue in nonpayable function
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user