diff options
author | chriseth <chris@ethereum.org> | 2017-09-01 18:31:24 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-09-06 19:52:29 +0800 |
commit | c83768c4260979b6d30185ef19352d27b161c3b0 (patch) | |
tree | 6549b555f1fbfbcae0f664a81b52aee841048a41 | |
parent | 1a1db1ec963935bffcabd6115cf99d04fd1d633b (diff) | |
download | dexon-solidity-c83768c4260979b6d30185ef19352d27b161c3b0.tar.gz dexon-solidity-c83768c4260979b6d30185ef19352d27b161c3b0.tar.zst dexon-solidity-c83768c4260979b6d30185ef19352d27b161c3b0.zip |
Fix tests
-rw-r--r-- | libsolidity/analysis/ViewPureChecker.cpp | 13 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index e5b433c2..705d61e8 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -292,11 +292,14 @@ void ViewPureChecker::endVisit(MemberAccess const& _memberAccess) void ViewPureChecker::endVisit(IndexAccess const& _indexAccess) { - solAssert(_indexAccess.indexExpression(), ""); - - bool writes = _indexAccess.annotation().lValueRequested; - if (_indexAccess.baseExpression().annotation().type->dataStoredIn(DataLocation::Storage)) - reportMutability(writes ? StateMutability::NonPayable : StateMutability::View, _indexAccess.location()); + if (!_indexAccess.indexExpression()) + solAssert(_indexAccess.annotation().type->category() == Type::Category::TypeType, ""); + else + { + bool writes = _indexAccess.annotation().lValueRequested; + if (_indexAccess.baseExpression().annotation().type->dataStoredIn(DataLocation::Storage)) + reportMutability(writes ? StateMutability::NonPayable : StateMutability::View, _indexAccess.location()); + } } void ViewPureChecker::endVisit(ModifierInvocation const& _modifier) diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 175a6f48..fa4d675c 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -6820,7 +6820,7 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library) { char const* sourceCode = R"( library Lib { - function find(uint16[] storage _haystack, uint16 _needle) pure returns (uint) + function find(uint16[] storage _haystack, uint16 _needle) view returns (uint) { for (uint i = 0; i < _haystack.length; ++i) if (_haystack[i] == _needle) |