diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index 54a7354e2..7ae45423d 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -190,7 +190,7 @@ void DeclarationTypeChecker::endVisit(UserDefinedTypeName const& _typeName) m_errorReporter.fatalTypeError( 5172_error, _typeName.location(), - "Name has to refer to a struct, enum or contract." + "Name has to refer to a user-defined value type, struct, enum or contract." ); } } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 8ec9f649d..ce5b2c255 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -3982,7 +3982,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) path->location(), "The function \"" + joinHumanReadable(path->path(), ".") + "\" "+ "needs to return exactly one value of type " + - functionType->parameterTypesIncludingSelf().front()->humanReadableName() + + functionType->parameterTypesIncludingSelf().front()->canonicalName() + " to be used for the operator " + TokenTraits::friendlyName(*operator_) + "." diff --git a/test/libsolidity/syntaxTests/errors/error_as_function_param.sol b/test/libsolidity/syntaxTests/errors/error_as_function_param.sol index 3741687f6..c2dff6783 100644 --- a/test/libsolidity/syntaxTests/errors/error_as_function_param.sol +++ b/test/libsolidity/syntaxTests/errors/error_as_function_param.sol @@ -1,4 +1,4 @@ error E(uint); function f(E x) pure returns (uint) {} // ---- -// TypeError 5172: (26-27): Name has to refer to a struct, enum or contract. +// TypeError 5172: (26-27): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/errors/using_2.sol b/test/libsolidity/syntaxTests/errors/using_2.sol index 2f60f3d04..be04d5f91 100644 --- a/test/libsolidity/syntaxTests/errors/using_2.sol +++ b/test/libsolidity/syntaxTests/errors/using_2.sol @@ -9,4 +9,4 @@ contract C { } } // ---- -// TypeError 5172: (91-92): Name has to refer to a struct, enum or contract. +// TypeError 5172: (91-92): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/errors/weird3.sol b/test/libsolidity/syntaxTests/errors/weird3.sol index c81266969..ab8c0c94d 100644 --- a/test/libsolidity/syntaxTests/errors/weird3.sol +++ b/test/libsolidity/syntaxTests/errors/weird3.sol @@ -4,4 +4,4 @@ contract C { E x; } // ---- -// TypeError 5172: (29-30): Name has to refer to a struct, enum or contract. +// TypeError 5172: (29-30): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/errors/weird4.sol b/test/libsolidity/syntaxTests/errors/weird4.sol index be1ef90b6..e2ae1b969 100644 --- a/test/libsolidity/syntaxTests/errors/weird4.sol +++ b/test/libsolidity/syntaxTests/errors/weird4.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 5172: (64-65): Name has to refer to a struct, enum or contract. +// TypeError 5172: (64-65): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/identifier_collision_return_declare.sol b/test/libsolidity/syntaxTests/iceRegressionTests/identifier_collision_return_declare.sol index b2d10d205..cfafeea81 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/identifier_collision_return_declare.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/identifier_collision_return_declare.sol @@ -2,4 +2,4 @@ contract C { function ( uint ) external returns ( a [ ] calldata ) public a = ( 1 / 2 ) ; } // ---- -// TypeError 5172: (58-59): Name has to refer to a struct, enum or contract. +// TypeError 5172: (58-59): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol index 0c7b80e03..07b1760c6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol @@ -6,4 +6,4 @@ contract test { } } // ---- -// TypeError 5172: (77-80): Name has to refer to a struct, enum or contract. +// TypeError 5172: (77-80): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol index 589772a9d..58c2c3637 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol @@ -7,4 +7,4 @@ contract test { } } // ---- -// TypeError 5172: (77-80): Name has to refer to a struct, enum or contract. +// TypeError 5172: (77-80): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol index c1cb83e47..cbdeb5139 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol @@ -7,4 +7,4 @@ contract test { } } // ---- -// TypeError 5172: (85-88): Name has to refer to a struct, enum or contract. +// TypeError 5172: (85-88): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/operators/custom/operator_with_different_param_return_types.sol b/test/libsolidity/syntaxTests/operators/custom/operator_with_different_param_return_types.sol index 8c4be929c..4f80eb33c 100644 --- a/test/libsolidity/syntaxTests/operators/custom/operator_with_different_param_return_types.sol +++ b/test/libsolidity/syntaxTests/operators/custom/operator_with_different_param_return_types.sol @@ -1,9 +1,18 @@ type Int is int128; + +struct S { + int128 i; +} + using { add as +, sub as -, mul as *, div as / } for Int; +using { + bitor as | +} for S; + function add(Int, Int) pure returns (Int) { return Int.wrap(1); } @@ -19,7 +28,14 @@ function mul(int128, int256) pure returns (Int) { function div(Int, Int) pure returns (int256) { return 3; } + +function bitor(S storage, S storage) pure returns (S memory) { + return S(1); +} + + // ---- -// TypeError 3100: (42-45): The function "sub" cannot be bound to the type "Int" because the type cannot be implicitly converted to the first argument of the function ("int128"). -// TypeError 3100: (56-59): The function "mul" cannot be bound to the type "Int" because the type cannot be implicitly converted to the first argument of the function ("int128"). -// TypeError 7743: (66-69): The function "div" needs to return exactly one value of type Int to be used for the operator /. +// TypeError 3100: (71-74): The function "sub" cannot be bound to the type "Int" because the type cannot be implicitly converted to the first argument of the function ("int128"). +// TypeError 3100: (85-88): The function "mul" cannot be bound to the type "Int" because the type cannot be implicitly converted to the first argument of the function ("int128"). +// TypeError 7743: (95-98): The function "div" needs to return exactly one value of type Int to be used for the operator /. +// TypeError 7743: (128-133): The function "bitor" needs to return exactly one value of type S to be used for the operator |. diff --git a/test/libsolidity/syntaxTests/scoping/name_shadowing_function_parameter_vs_struct_enum.sol b/test/libsolidity/syntaxTests/scoping/name_shadowing_function_parameter_vs_struct_enum.sol index 61441ece6..fe4cbce66 100644 --- a/test/libsolidity/syntaxTests/scoping/name_shadowing_function_parameter_vs_struct_enum.sol +++ b/test/libsolidity/syntaxTests/scoping/name_shadowing_function_parameter_vs_struct_enum.sol @@ -17,4 +17,4 @@ contract C { // Warning 2519: (207-226): This declaration shadows an existing declaration. // Warning 2519: (228-254): This declaration shadows an existing declaration. // Warning 2519: (314-327): This declaration shadows an existing declaration. -// TypeError 5172: (104-114): Name has to refer to a struct, enum or contract. +// TypeError 5172: (104-114): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/scoping/name_shadowing_function_return_parameter_vs_struct_enum.sol b/test/libsolidity/syntaxTests/scoping/name_shadowing_function_return_parameter_vs_struct_enum.sol index ed4b2e0d2..df95186e5 100644 --- a/test/libsolidity/syntaxTests/scoping/name_shadowing_function_return_parameter_vs_struct_enum.sol +++ b/test/libsolidity/syntaxTests/scoping/name_shadowing_function_return_parameter_vs_struct_enum.sol @@ -17,4 +17,4 @@ contract C { // Warning 2519: (249-268): This declaration shadows an existing declaration. // Warning 2519: (270-296): This declaration shadows an existing declaration. // Warning 2519: (317-330): This declaration shadows an existing declaration. -// TypeError 5172: (124-134): Name has to refer to a struct, enum or contract. +// TypeError 5172: (124-134): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/structs/member_type_func.sol b/test/libsolidity/syntaxTests/structs/member_type_func.sol index 1200fa7af..5f1f72bd3 100644 --- a/test/libsolidity/syntaxTests/structs/member_type_func.sol +++ b/test/libsolidity/syntaxTests/structs/member_type_func.sol @@ -4,4 +4,4 @@ contract C { function g(function(S memory) external) public {} } // ---- -// TypeError 5172: (50-51): Name has to refer to a struct, enum or contract. +// TypeError 5172: (50-51): Name has to refer to a user-defined value type, struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/types/constant_of_invalid_function_type.sol b/test/libsolidity/syntaxTests/types/constant_of_invalid_function_type.sol index a371cb13b..68c31081b 100644 --- a/test/libsolidity/syntaxTests/types/constant_of_invalid_function_type.sol +++ b/test/libsolidity/syntaxTests/types/constant_of_invalid_function_type.sol @@ -4,4 +4,4 @@ contract C { } // ---- -// TypeError 5172: (77-78): Name has to refer to a struct, enum or contract. +// TypeError 5172: (77-78): Name has to refer to a user-defined value type, struct, enum or contract.