Add user operator tests for builtin types

This commit is contained in:
wechman 2022-08-08 09:07:01 +02:00
parent 6feb8aea73
commit e0c688d55d
3 changed files with 26 additions and 2 deletions

View File

@ -3943,7 +3943,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
m_errorReporter.typeError( m_errorReporter.typeError(
5332_error, 5332_error,
path->location(), 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; continue;
} }

View File

@ -1,4 +1,21 @@
using {f as +} for uint; 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) {} 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.

View File

@ -0,0 +1,7 @@
using {f as +} for L;
function f() {}
library L {}
// ----
// TypeError 1130: (19-20): Invalid use of a library name.