fixup! User-defined operators: Tests

This commit is contained in:
Kamil Śliwak 2023-01-20 11:22:57 +01:00
parent cd83d09cf3
commit bf29ae7669
10 changed files with 31 additions and 13 deletions

View File

@ -2,7 +2,6 @@ type Int is int16;
using {add as +} for Int; using {add as +} for Int;
function add(Int, Int) returns (Int) { function add(Int, Int) returns (Int) {
B b = new B(); B b = new B();
return b.f(); return b.f();

View File

@ -0,0 +1,19 @@
type Int is int16;
using {add as +} for Int;
function add(Int, Int) pure returns (Int) {
return b.f();
}
contract B {
function f() external pure returns (Int) {}
}
contract C {
function test() public returns (Int) {
return Int.wrap(0) + Int.wrap(0);
}
}
// ----
// DeclarationError 7576: (102-103): Undeclared identifier.

View File

@ -1,8 +1,8 @@
using {fc as +} for C; using {fc as +} for C;
using {fa as +} for A; using {fa as +} for A;
function fc(C, C) returns (C) {} function fc(C, C) pure returns (C) {}
function fa(A, A) returns (A) {} function fa(A, A) pure returns (A) {}
contract C {} contract C {}
abstract contract A {} abstract contract A {}

View File

@ -1,6 +1,6 @@
using {f as +} for I; using {f as +} for I;
function f(I, I) returns (I) {} function f(I, I) pure returns (I) {}
interface I {} interface I {}
// ---- // ----

View File

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

View File

@ -1,9 +1,9 @@
type Int is int; type Int is int;
function add(Int, Int) returns (Int) {} function add(Int, Int) pure returns (Int) {}
contract C { contract C {
using {add as +} for *; using {add as +} for *;
} }
// ---- // ----
// SyntaxError 3349: (76-99): The type has to be specified explicitly when attaching specific functions. // SyntaxError 3349: (81-104): The type has to be specified explicitly when attaching specific functions.

View File

@ -3,7 +3,7 @@ type Int is int;
contract C { contract C {
using {add as +} for Int; using {add as +} for Int;
function add(Int, Int) public returns (Int) {} function add(Int, Int) public pure returns (Int) {}
} }
// ---- // ----
// TypeError 4167: (42-45): Only file-level functions and library functions can be attached to a type in a "using" statement // TypeError 4167: (42-45): Only file-level functions and library functions can be attached to a type in a "using" statement

View File

@ -3,7 +3,7 @@ type Int is int;
using {C.add as +} for Int; using {C.add as +} for Int;
contract C { contract C {
function add(Int, Int) public returns (Int) { function add(Int, Int) public pure returns (Int) {
return 0; return 0;
} }
} }

View File

@ -1,8 +1,8 @@
type Int is int8; type Int is int8;
contract C { contract C {
function(Int, Int) external returns (Int) ptr; function(Int, Int) external pure returns (Int) ptr;
using {ptr as +} for Int; using {ptr as +} for Int;
} }
// ---- // ----
// TypeError 8187: (94-97): Expected function name. // TypeError 8187: (99-102): Expected function name.

View File

@ -1,11 +1,11 @@
type Int is int128; type Int is int128;
library L { library L {
function externalOperator(Int, Int) external returns (Int) {} function externalOperator(Int, Int) external pure returns (Int) {}
} }
// FIXME: Not being able to use external library functions in 'using for' is a bug. // FIXME: Not being able to use external library functions in 'using for' is a bug.
// https://github.com/ethereum/solidity/issues/13765 // https://github.com/ethereum/solidity/issues/13765
using {L.externalOperator as +} for Int; using {L.externalOperator as +} for Int;
// ---- // ----
// DeclarationError 7920: (246-264): Identifier not found or not unique. // DeclarationError 7920: (251-269): Identifier not found or not unique.