From ec27e569b0da6650238a9b48aa53d120184001ed Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 29 Aug 2017 17:08:08 +0200 Subject: Do not report on overriding function and only warn for view. --- libsolidity/analysis/ViewPureChecker.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 0e2cfacf..b4b7f372 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -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; } -- cgit