mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not report on overriding function and only warn for view.
This commit is contained in:
parent
342367d5dc
commit
ec27e569b0
@ -131,29 +131,36 @@ void ViewPureChecker::endVisit(InlineAssembly const& _inlineAssembly)
|
||||
reportMutability(StateMutability::NonPayable, _inlineAssembly);
|
||||
}
|
||||
|
||||
void ViewPureChecker::reportMutability(StateMutability _mutability, const ASTNode& _node)
|
||||
void ViewPureChecker::reportMutability(StateMutability _mutability, ASTNode const& _node)
|
||||
{
|
||||
if (m_currentFunction && m_currentFunction->stateMutability() < _mutability)
|
||||
{
|
||||
m_errors = true;
|
||||
string text;
|
||||
if (_mutability == StateMutability::View)
|
||||
m_errorReporter.typeError(
|
||||
_node.location(),
|
||||
"Function declared as pure, but this expression reads from the environment or state and thus "
|
||||
"requires \"view\"."
|
||||
);
|
||||
text =
|
||||
"Function declared as pure, but this expression reads from the "
|
||||
"environment or state and thus requires \"view\".";
|
||||
else if (_mutability == StateMutability::NonPayable)
|
||||
m_errorReporter.typeError(
|
||||
_node.location(),
|
||||
text =
|
||||
"Function declared as " +
|
||||
stateMutabilityToString(m_currentFunction->stateMutability()) +
|
||||
", but this expression modifies the state and thus "
|
||||
"requires non-payable (the default) or payable."
|
||||
);
|
||||
"requires non-payable (the default) or payable.";
|
||||
else
|
||||
solAssert(false, "");
|
||||
|
||||
if (m_currentFunction->stateMutability() == StateMutability::View)
|
||||
// Change this to error with 0.5.0
|
||||
m_errorReporter.warning(_node.location(), text);
|
||||
else if (m_currentFunction->stateMutability() == StateMutability::Pure)
|
||||
{
|
||||
m_errors = true;
|
||||
m_errorReporter.typeError(_node.location(), text);
|
||||
}
|
||||
else
|
||||
solAssert(false, "");
|
||||
}
|
||||
if (_mutability >= m_currentBestMutability)
|
||||
if (_mutability > m_currentBestMutability)
|
||||
m_currentBestMutability = _mutability;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user