aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-05-11 16:40:32 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-07-04 16:14:58 +0800
commit7ea8365ab08fae7a30cfff55e7d53f78bb1a2c36 (patch)
tree444f47a91f7544bda9a1e5a6abf5d339daee7da9 /libsolidity
parent533d5d4b1cc4374decc704de8c86ad4cef6214fc (diff)
downloaddexon-solidity-7ea8365ab08fae7a30cfff55e7d53f78bb1a2c36.tar.gz
dexon-solidity-7ea8365ab08fae7a30cfff55e7d53f78bb1a2c36.tar.zst
dexon-solidity-7ea8365ab08fae7a30cfff55e7d53f78bb1a2c36.zip
Remove v050 check for enforcing "view" in ViewPureChecker.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp38
-rw-r--r--libsolidity/analysis/ViewPureChecker.h1
2 files changed, 13 insertions, 26 deletions
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 107eb3aa..18c642c3 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -116,31 +116,22 @@ private:
bool ViewPureChecker::check()
{
- // The bool means "enforce view with errors".
- vector<pair<ContractDefinition const*, bool>> contracts;
+ vector<ContractDefinition const*> contracts;
for (auto const& node: m_ast)
{
SourceUnit const* source = dynamic_cast<SourceUnit const*>(node.get());
solAssert(source, "");
- bool enforceView = source->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
- for (ContractDefinition const* c: source->filteredNodes<ContractDefinition>(source->nodes()))
- contracts.emplace_back(c, enforceView);
+ contracts += source->filteredNodes<ContractDefinition>(source->nodes());
}
// Check modifiers first to infer their state mutability.
for (auto const& contract: contracts)
- {
- m_enforceViewWithError = contract.second;
- for (ModifierDefinition const* mod: contract.first->functionModifiers())
+ for (ModifierDefinition const* mod: contract->functionModifiers())
mod->accept(*this);
- }
for (auto const& contract: contracts)
- {
- m_enforceViewWithError = contract.second;
- contract.first->accept(*this);
- }
+ contract->accept(*this);
return !m_errors;
}
@@ -232,17 +223,20 @@ void ViewPureChecker::reportMutability(StateMutability _mutability, SourceLocati
{
if (m_currentFunction && m_currentFunction->stateMutability() < _mutability)
{
- string text;
if (_mutability == StateMutability::View)
- text =
+ m_errorReporter.typeError(
+ _location,
"Function declared as pure, but this expression (potentially) reads from the "
- "environment or state and thus requires \"view\".";
+ "environment or state and thus requires \"view\"."
+ );
else if (_mutability == StateMutability::NonPayable)
- text =
+ m_errorReporter.typeError(
+ _location,
"Function declared as " +
stateMutabilityToString(m_currentFunction->stateMutability()) +
", but this expression (potentially) modifies the state and thus "
- "requires non-payable (the default) or payable.";
+ "requires non-payable (the default) or payable."
+ );
else
solAssert(false, "");
@@ -251,13 +245,7 @@ void ViewPureChecker::reportMutability(StateMutability _mutability, SourceLocati
m_currentFunction->stateMutability() == StateMutability::Pure,
""
);
- if (!m_enforceViewWithError && m_currentFunction->stateMutability() == StateMutability::View)
- m_errorReporter.warning(_location, text);
- else
- {
- m_errors = true;
- m_errorReporter.typeError(_location, text);
- }
+ m_errors = true;
}
if (_mutability > m_currentBestMutability)
m_currentBestMutability = _mutability;
diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h
index 0b882cd8..3db52e7e 100644
--- a/libsolidity/analysis/ViewPureChecker.h
+++ b/libsolidity/analysis/ViewPureChecker.h
@@ -71,7 +71,6 @@ private:
ErrorReporter& m_errorReporter;
bool m_errors = false;
- bool m_enforceViewWithError = false;
StateMutability m_currentBestMutability = StateMutability::Payable;
FunctionDefinition const* m_currentFunction = nullptr;
std::map<ModifierDefinition const*, StateMutability> m_inferredMutability;