aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ViewPureChecker.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-13 16:49:50 +0800
committerchriseth <chris@ethereum.org>2018-02-13 18:00:59 +0800
commit5916cf1e0ace5d9855af4d785c22c742cf106b8a (patch)
tree086046177d246cbdec3e8907445dff0e36bca24a /libsolidity/analysis/ViewPureChecker.cpp
parent729c6a95f8615586969e206b0b796011b3824adf (diff)
downloaddexon-solidity-5916cf1e0ace5d9855af4d785c22c742cf106b8a.tar.gz
dexon-solidity-5916cf1e0ace5d9855af4d785c22c742cf106b8a.tar.zst
dexon-solidity-5916cf1e0ace5d9855af4d785c22c742cf106b8a.zip
Allow `this.f.selector` to be pure.
Diffstat (limited to 'libsolidity/analysis/ViewPureChecker.cpp')
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 6257ac6d..13c3ab68 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -275,6 +275,22 @@ void ViewPureChecker::endVisit(FunctionCall const& _functionCall)
reportMutability(mut, _functionCall.location());
}
+bool ViewPureChecker::visit(MemberAccess const& _memberAccess)
+{
+ // Catch the special case of `this.f.selector` which is a pure expression.
+ ASTString const& member = _memberAccess.memberName();
+ if (
+ _memberAccess.expression().annotation().type->category() == Type::Category::Function &&
+ member == "selector"
+ )
+ if (auto const* expr = dynamic_cast<MemberAccess const*>(&_memberAccess.expression()))
+ if (auto const* exprInt = dynamic_cast<Identifier const*>(&expr->expression()))
+ if (exprInt->name() == "this")
+ // Do not continue visiting.
+ return false;
+ return true;
+}
+
void ViewPureChecker::endVisit(MemberAccess const& _memberAccess)
{
StateMutability mutability = StateMutability::Pure;