From 8bb8373436b393e3c19f324993d60ea27a67ca9d Mon Sep 17 00:00:00 2001 From: wechman Date: Fri, 2 Sep 2022 13:47:09 +0200 Subject: [PATCH] Fix the using directive implicit conversion error message. --- libsolidity/analysis/TypeChecker.cpp | 2 +- .../using/free_functions_implicit_conversion_err.sol | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index cac55ceed..7499dc901 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -3910,7 +3910,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->canonicalName() + "\" because the type cannot be implicitly converted to the first argument" + " of the function (\"" + functionType->selfType()->humanReadableName() + "\")" + ( diff --git a/test/libsolidity/syntaxTests/using/free_functions_implicit_conversion_err.sol b/test/libsolidity/syntaxTests/using/free_functions_implicit_conversion_err.sol index 36f3f3032..9c78a735d 100644 --- a/test/libsolidity/syntaxTests/using/free_functions_implicit_conversion_err.sol +++ b/test/libsolidity/syntaxTests/using/free_functions_implicit_conversion_err.sol @@ -1,8 +1,14 @@ +struct S { + uint8 x; +} + function id(uint16 x) pure returns(uint16) { return x; } contract C { using {id} for uint256; + using {id} for S; } // ---- -// TypeError 3100: (85-87): 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: (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 "S" because the type cannot be implicitly converted to the first argument of the function ("uint16").