diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 15 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 29 |
2 files changed, 24 insertions, 20 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index d4de219a..6aee260e 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -142,6 +142,7 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) bool const v050 = m_currentContract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); if (MagicType const* type = dynamic_cast<MagicType const*>(_memberAccess.expression().annotation().type.get())) + { if (type->kind() == MagicType::Kind::Message && _memberAccess.memberName() == "gas") { if (v050) @@ -155,6 +156,20 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) "\"msg.gas\" has been deprecated in favor of \"gasleft()\"" ); } + if (type->kind() == MagicType::Kind::Block && _memberAccess.memberName() == "blockhash") + { + if (v050) + m_errorReporter.typeError( + _memberAccess.location(), + "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\"" + ); + else + m_errorReporter.warning( + _memberAccess.location(), + "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\"" + ); + } + } if (m_nonPayablePublic && !m_library) if (MagicType const* type = dynamic_cast<MagicType const*>(_memberAccess.expression().annotation().type.get())) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index f4559eda..41700e28 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -3002,30 +3002,19 @@ bool MagicType::operator==(Type const& _other) const return other.m_kind == m_kind; } -MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const* _contract) const +MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const { - const bool v050 = _contract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); switch (m_kind) { case Kind::Block: - { - std::vector<MemberList::Member> members = { - {"coinbase", make_shared<IntegerType>(160, IntegerType::Modifier::Address)}, - {"timestamp", make_shared<IntegerType>(256)}, - {"difficulty", make_shared<IntegerType>(256)}, - {"number", make_shared<IntegerType>(256)}, - {"gaslimit", make_shared<IntegerType>(256)} - }; - - if (!v050) - { - auto blockhashFun = make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"}, - FunctionType::Kind::BlockHash, false, StateMutability::View); - - members.emplace_back("blockhash", blockhashFun); - } - return MemberList::MemberMap(members); - } + return MemberList::MemberMap({ + {"coinbase", make_shared<IntegerType>(160, IntegerType::Modifier::Address)}, + {"timestamp", make_shared<IntegerType>(256)}, + {"blockhash", make_shared<FunctionType>(strings{"uint"}, strings{"bytes32"}, FunctionType::Kind::BlockHash, false, StateMutability::View)}, + {"difficulty", make_shared<IntegerType>(256)}, + {"number", make_shared<IntegerType>(256)}, + {"gaslimit", make_shared<IntegerType>(256)} + }); case Kind::Message: return MemberList::MemberMap({ {"sender", make_shared<IntegerType>(160, IntegerType::Modifier::Address)}, |