aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-07-19 15:24:27 +0800
committerGitHub <noreply@github.com>2018-07-19 15:24:27 +0800
commite3c2f20f6e8c7919a6733fa736a3a222028f213c (patch)
tree8905905bc8c29b9fc3acc08ee4f876cd8fd4ff07 /libsolidity/analysis
parentccb5fccee5f7eea8993f2cbc77217abbccae36ce (diff)
parentfaa9c221d41c45e12411c654919f318f6e7fc98f (diff)
downloaddexon-solidity-e3c2f20f6e8c7919a6733fa736a3a222028f213c.tar.gz
dexon-solidity-e3c2f20f6e8c7919a6733fa736a3a222028f213c.tar.zst
dexon-solidity-e3c2f20f6e8c7919a6733fa736a3a222028f213c.zip
Merge pull request #4439 from ethereum/address_members
[BREAKING] Enforce address members not accessible by contract instance
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 92e5c978..8536e934 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1930,6 +1930,9 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
else
++it;
}
+
+ auto& annotation = _memberAccess.annotation();
+
if (possibleMembers.size() == 0)
{
if (initialMemberCount == 0)
@@ -1947,11 +1950,21 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
" outside of storage."
);
}
+ string errorMsg = "Member \"" + memberName + "\" not found or not visible "
+ "after argument-dependent lookup in " + exprType->toString() +
+ (memberName == "value" ? " - did you forget the \"payable\" modifier?" : ".");
+ if (exprType->category() == Type::Category::Contract)
+ for (auto const& addressMember: IntegerType(160, IntegerType::Modifier::Address).nativeMembers(nullptr))
+ if (addressMember.name == memberName)
+ {
+ Identifier const* var = dynamic_cast<Identifier const*>(&_memberAccess.expression());
+ string varName = var ? var->name() : "...";
+ errorMsg += " Use \"address(" + varName + ")." + memberName + "\" to access this address member.";
+ break;
+ }
m_errorReporter.fatalTypeError(
_memberAccess.location(),
- "Member \"" + memberName + "\" not found or not visible "
- "after argument-dependent lookup in " + exprType->toString() +
- (memberName == "value" ? " - did you forget the \"payable\" modifier?" : ".")
+ errorMsg
);
}
else if (possibleMembers.size() > 1)
@@ -1962,7 +1975,6 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
(memberName == "value" ? " - did you forget the \"payable\" modifier?" : ".")
);
- auto& annotation = _memberAccess.annotation();
annotation.referencedDeclaration = possibleMembers.front().declaration;
annotation.type = possibleMembers.front().type;
@@ -1995,20 +2007,6 @@ 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,"
- " for example use \"address(contract)." + memberName + "\" instead."
- );
- }
-
// Warn about using send or transfer with a non-payable fallback function.
if (auto callType = dynamic_cast<FunctionType const*>(type(_memberAccess).get()))
{