diff options
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/ViewPureChecker.cpp | 16 | ||||
-rw-r--r-- | libsolidity/analysis/ViewPureChecker.h | 1 |
2 files changed, 17 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; diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h index fec060b6..0b882cd8 100644 --- a/libsolidity/analysis/ViewPureChecker.h +++ b/libsolidity/analysis/ViewPureChecker.h @@ -56,6 +56,7 @@ private: virtual bool visit(ModifierDefinition const& _modifierDef) override; virtual void endVisit(ModifierDefinition const& _modifierDef) override; virtual void endVisit(Identifier const& _identifier) override; + virtual bool visit(MemberAccess const& _memberAccess) override; virtual void endVisit(MemberAccess const& _memberAccess) override; virtual void endVisit(IndexAccess const& _indexAccess) override; virtual void endVisit(ModifierInvocation const& _modifier) override; |