diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 267a772e1..eff7f3a3c 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -3943,7 +3943,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) m_errorReporter.typeError( 5332_error, path->location(), - "Operators can only be implemented for user-defined types and not for contracts." + "Operators can only be implemented for user-defined value types and structs." ); continue; } diff --git a/test/libsolidity/syntaxTests/using/operator_for_builtin.sol b/test/libsolidity/syntaxTests/using/operator_for_builtin.sol index e2b9ee5d9..44c1d66b5 100644 --- a/test/libsolidity/syntaxTests/using/operator_for_builtin.sol +++ b/test/libsolidity/syntaxTests/using/operator_for_builtin.sol @@ -1,4 +1,21 @@ using {f as +} for uint; +using {f as +} for uint[2]; +using {f as +} for mapping(uint => uint); +using {f as +} for function (uint) pure returns (uint); +using {f as +} for I; +using {f as +} for C; +using {f as +} for string; + function f(uint, uint) pure returns (uint) {} + +interface I {} +contract C {} + // ---- -// TypeError 5332: (7-8): Operators can only be implemented for user-defined types and not for contracts. +// TypeError 5332: (7-8): Operators can only be implemented for user-defined value types and structs. +// TypeError 5332: (32-33): Operators can only be implemented for user-defined value types and structs. +// TypeError 5332: (60-61): Operators can only be implemented for user-defined value types and structs. +// TypeError 5332: (102-103): Operators can only be implemented for user-defined value types and structs. +// TypeError 5332: (158-159): Operators can only be implemented for user-defined value types and structs. +// TypeError 5332: (180-181): Operators can only be implemented for user-defined value types and structs. +// TypeError 5332: (202-203): Operators can only be implemented for user-defined value types and structs. diff --git a/test/libsolidity/syntaxTests/using/operator_for_library.sol b/test/libsolidity/syntaxTests/using/operator_for_library.sol new file mode 100644 index 000000000..bd3b5dfff --- /dev/null +++ b/test/libsolidity/syntaxTests/using/operator_for_library.sol @@ -0,0 +1,7 @@ +using {f as +} for L; + +function f() {} +library L {} + +// ---- +// TypeError 1130: (19-20): Invalid use of a library name.