Make sure "value" error hint is only displayed in the right context

Before, the hint would be shown for any "value" member, even a user-specified one.
This commit is contained in:
Mathias Baumann
2019-02-18 16:29:57 +01:00
parent d32670760c
commit 093b9ced97
11 changed files with 32 additions and 21 deletions
+16 -12
View File
@@ -2046,20 +2046,24 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
}
string errorMsg = "Member \"" + memberName + "\" not found or not visible "
"after argument-dependent lookup in " + exprType->toString() + ".";
if (memberName == "value")
{
errorMsg.pop_back();
errorMsg += " - did you forget the \"payable\" modifier?";
}
else if (auto const& funType = dynamic_pointer_cast<FunctionType const>(exprType))
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 (memberName == "value")
{
if (funType->kind() == FunctionType::Kind::Creation)
errorMsg = "Constructor for " + t.front()->toString() + " must be payable for member \"value\" to be available.";
else
errorMsg = "Member \"value\" is only available for payable functions.";
}
else if (
t.size() == 1 &&
(t.front()->category() == Type::Category::Struct ||
t.front()->category() == Type::Category::Contract)
)
errorMsg += " Did you intend to call the function?";
}
else if (exprType->category() == Type::Category::Contract)
{