diff options
author | Martin Diz <gitlab@martindiz.com.ar> | 2018-10-04 23:31:52 +0800 |
---|---|---|
committer | Martin Diz <gitlab@martindiz.com.ar> | 2018-10-10 22:53:53 +0800 |
commit | ef25454a048bee9049c6076421d08732aeacb8bb (patch) | |
tree | 6d332b3126a8bfa6cd500eaa858e0dd45c00d7cb /libsolidity | |
parent | dd4acda73a38ff83ab520e05b552012c324998d5 (diff) | |
download | dexon-solidity-ef25454a048bee9049c6076421d08732aeacb8bb.tar.gz dexon-solidity-ef25454a048bee9049c6076421d08732aeacb8bb.tar.zst dexon-solidity-ef25454a048bee9049c6076421d08732aeacb8bb.zip |
Improved error message for lookup in function types.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 39ea494d..5ffdda57 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2141,8 +2141,25 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) ); } string errorMsg = "Member \"" + memberName + "\" not found or not visible " - "after argument-dependent lookup in " + exprType->toString() + - (memberName == "value" ? " - did you forget the \"payable\" modifier?" : "."); + "after argument-dependent lookup in " + exprType->toString() + "."; + if (memberName == "value") + { + errorMsg.pop_back(); + errorMsg += " - did you forget the \"payable\" modifier?"; + } + else if (exprType->category() == Type::Category::Function) + { + if (auto const& funType = dynamic_pointer_cast<FunctionType const>(exprType)) + { + auto const& t = funType->returnParameterTypes(); + if (t.size() == 1) + if ( + t.front()->category() == Type::Category::Contract || + t.front()->category() == Type::Category::Struct + ) + errorMsg += " Did you intend to call the function?"; + } + } if (exprType->category() == Type::Category::Contract) for (auto const& addressMember: AddressType::addressPayable().nativeMembers(nullptr)) if (addressMember.name == memberName) |