mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ViewPureChecker::reportMutability: don't check visibility on constructors.
This commit is contained in:
@@ -261,21 +261,24 @@ void ViewPureChecker::reportMutability(
|
||||
{
|
||||
// We do not warn for library functions because they cannot be payable anyway.
|
||||
// Also internal functions should be allowed to use `msg.value`.
|
||||
if (m_currentFunction->isPublic() && !m_currentFunction->libraryFunction())
|
||||
if ((m_currentFunction->isConstructor() || m_currentFunction->isPublic()) && !m_currentFunction->libraryFunction())
|
||||
{
|
||||
if (_nestedLocation)
|
||||
m_errorReporter.typeError(
|
||||
4006_error,
|
||||
_location,
|
||||
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."
|
||||
m_currentFunction->isConstructor() ?
|
||||
"This modifier uses \"msg.value\" or \"callvalue()\" and thus the constructor has to be payable."
|
||||
: "This modifier uses \"msg.value\" or \"callvalue()\" and thus the function has to be payable or internal."
|
||||
);
|
||||
else
|
||||
m_errorReporter.typeError(
|
||||
5887_error,
|
||||
_location,
|
||||
"\"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_currentFunction->isConstructor() ?
|
||||
"\"msg.value\" and \"callvalue()\" can only be used in payable constructors. Make the constructor \"payable\" to avoid this error."
|
||||
: "\"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