From fd60c1cf86e69931fda47bdd187f444550ca785f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 20 Sep 2017 14:54:41 +0100 Subject: Warn if using address overloads on contracts --- libsolidity/analysis/TypeChecker.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libsolidity') diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 9846a0d0..ac8b2b63 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1831,6 +1831,16 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) if (exprType->category() == Type::Category::Contract) { + // Warn about using address members on contracts + for (auto const& addressMember: IntegerType(160, IntegerType::Modifier::Address).nativeMembers(nullptr)) + if (addressMember.name == memberName && *annotation.type == *addressMember.type) + m_errorReporter.warning( + _memberAccess.location(), + "Using contract member \"" + memberName +"\" inherited from the address type is deprecated." + + " Convert the contract to \"address\" type to access the member." + ); + + // Warn about using send or transfer with a non-payable fallback function. if (auto callType = dynamic_cast(type(_memberAccess).get())) { auto kind = callType->kind(); -- cgit From 1ceb0b04c1ce117366cde88eb8c3bebb1a5e9598 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 5 Mar 2018 15:55:02 +0100 Subject: Assert that address members are not present on contract types in 0.5.0. --- libsolidity/analysis/TypeChecker.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libsolidity') diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index ac8b2b63..106a2c8e 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1832,13 +1832,17 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) if (exprType->category() == Type::Category::Contract) { // Warn about using address members on contracts + bool v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); for (auto const& addressMember: IntegerType(160, IntegerType::Modifier::Address).nativeMembers(nullptr)) if (addressMember.name == memberName && *annotation.type == *addressMember.type) + { + solAssert(!v050, "Address member still present on contract in v0.5.0."); m_errorReporter.warning( _memberAccess.location(), "Using contract member \"" + memberName +"\" inherited from the address type is deprecated." + " Convert the contract to \"address\" type to access the member." ); + } // Warn about using send or transfer with a non-payable fallback function. if (auto callType = dynamic_cast(type(_memberAccess).get())) -- cgit