Don't include location in a message about binding function to a type

This commit is contained in:
wechman 2022-09-02 13:47:09 +02:00 committed by Kamil Śliwak
parent d5428af5bb
commit 4c9a58eb0f
3 changed files with 8 additions and 3 deletions

View File

@ -3798,7 +3798,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
path->location(),
"The function \"" + joinHumanReadable(path->path(), ".") + "\" " +
"does not have any parameters, and therefore cannot be bound to the type \"" +
(normalizedType ? normalizedType->humanReadableName() : "*") + "\"."
(normalizedType ? normalizedType->toString(true /* withoutDataLocation */) : "*") + "\"."
);
FunctionType const* functionType = dynamic_cast<FunctionType const&>(*functionDefinition.type()).asBoundFunction();
@ -3811,7 +3811,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
3100_error,
path->location(),
"The function \"" + joinHumanReadable(path->path(), ".") + "\" "+
"cannot be bound to the type \"" + _usingFor.typeName()->annotation().type->humanReadableName() +
"cannot be bound to the type \"" + _usingFor.typeName()->annotation().type->toString(true /* withoutDataLocation */) +
"\" because the type cannot be implicitly converted to the first argument" +
" of the function (\"" + functionType->selfType()->humanReadableName() + "\")" +
(

View File

@ -11,4 +11,4 @@ contract C {
}
// ----
// TypeError 3100: (112-114): The function "id" cannot be bound to the type "uint256" because the type cannot be implicitly converted to the first argument of the function ("uint16").
// TypeError 3100: (140-142): The function "id" cannot be bound to the type "struct S storage pointer" because the type cannot be implicitly converted to the first argument of the function ("uint16").
// TypeError 3100: (140-142): The function "id" cannot be bound to the type "struct S" because the type cannot be implicitly converted to the first argument of the function ("uint16").

View File

@ -0,0 +1,5 @@
struct S { uint8 x; }
function f() {}
using {f} for S;
// ----
// TypeError 4731: (45-46): The function "f" does not have any parameters, and therefore cannot be bound to the type "struct S".