aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ViewPureChecker.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-29 23:08:08 +0800
committerchriseth <chris@ethereum.org>2017-09-06 19:50:49 +0800
commitec27e569b0da6650238a9b48aa53d120184001ed (patch)
treef8814535fafc598d22d28609c03ad47b10ac141d /libsolidity/analysis/ViewPureChecker.cpp
parent342367d5dcb897d1ef3bbc00853538859773ed37 (diff)
downloaddexon-solidity-ec27e569b0da6650238a9b48aa53d120184001ed.tar.gz
dexon-solidity-ec27e569b0da6650238a9b48aa53d120184001ed.tar.zst
dexon-solidity-ec27e569b0da6650238a9b48aa53d120184001ed.zip
Do not report on overriding function and only warn for view.
Diffstat (limited to 'libsolidity/analysis/ViewPureChecker.cpp')
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp31
1 files 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;
}