mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Reconstruct function definition for magic variables in overload error message.
This commit is contained in:
parent
c4441bac5b
commit
06588cde76
@ -2359,7 +2359,18 @@ bool TypeChecker::visit(Identifier const& _identifier)
|
||||
SecondarySourceLocation ssl;
|
||||
|
||||
for (Declaration const* declaration: annotation.overloadedDeclarations)
|
||||
ssl.append("Candidate:", declaration->location());
|
||||
if (declaration->location().isEmpty())
|
||||
{
|
||||
// Try to re-construct function definition
|
||||
string description;
|
||||
for (auto const& param: declaration->functionType(true)->parameterTypes())
|
||||
description += (description.empty() ? "" : ", ") + param->toString(false);
|
||||
description = "function " + _identifier.name() + "(" + description + ")";
|
||||
|
||||
ssl.append("Candidate: " + description, declaration->location());
|
||||
}
|
||||
else
|
||||
ssl.append("Candidate:", declaration->location());
|
||||
if (candidates.empty())
|
||||
m_errorReporter.fatalTypeError(_identifier.location(), ssl, "No matching declaration found after argument-dependent lookup.");
|
||||
else
|
||||
|
5
test/cmdlineTests/require_overload/err
Normal file
5
test/cmdlineTests/require_overload/err
Normal file
@ -0,0 +1,5 @@
|
||||
require_overload/input.sol:4:9: Error: No matching declaration found after argument-dependent lookup.
|
||||
require(this);
|
||||
^-----^
|
||||
Candidate: function require(bool)
|
||||
Candidate: function require(bool, string memory)
|
1
test/cmdlineTests/require_overload/exit
Normal file
1
test/cmdlineTests/require_overload/exit
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
test/cmdlineTests/require_overload/input.sol
Normal file
6
test/cmdlineTests/require_overload/input.sol
Normal file
@ -0,0 +1,6 @@
|
||||
pragma solidity >=0.0;
|
||||
contract C {
|
||||
function f() public pure {
|
||||
require(this);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user