mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
User-defined operators: Tests
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
type Int is int256;
|
||||
|
||||
function f() pure {
|
||||
Int a = Int.wrap(0);
|
||||
a + a;
|
||||
a >>> a;
|
||||
}
|
||||
|
||||
// ----
|
||||
// TypeError 2271: (70-75): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 2271: (81-88): Built-in binary operator >>> cannot be applied to types Int and Int.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
type Int is int256;
|
||||
|
||||
function f() pure {
|
||||
Int a = Int.wrap(0);
|
||||
-a;
|
||||
a++;
|
||||
}
|
||||
|
||||
// ----
|
||||
// TypeError 4907: (70-72): Built-in unary operator - cannot be applied to type Int. No matching user-defined operator found.
|
||||
// TypeError 9767: (78-81): Built-in unary operator ++ cannot be applied to type Int.
|
||||
@@ -0,0 +1,11 @@
|
||||
type Int is int;
|
||||
using {add as +} for Int global;
|
||||
using {unsub as -} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
function f() pure {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
type Int is int16;
|
||||
|
||||
using {add as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
function f() {
|
||||
Int a;
|
||||
a.add(a);
|
||||
}
|
||||
// ----
|
||||
// TypeError 9582: (130-135): Member "add" not found or not visible after argument-dependent lookup in Int.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
type Int is int16;
|
||||
|
||||
using {add as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
function f() {
|
||||
Int a;
|
||||
a.+(a);
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (132-133): Expected identifier but got '+'
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
==== Source: definition.sol ====
|
||||
import "type-and-binding.sol";
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: type-and-binding.sol ====
|
||||
import "definition.sol";
|
||||
|
||||
type Int is int;
|
||||
|
||||
using {add as +} for Int global;
|
||||
using {unsub as -} for Int global;
|
||||
|
||||
==== Source: use.sol ====
|
||||
import "type-and-binding.sol";
|
||||
|
||||
contract C {
|
||||
function f() pure public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
==== Source: binding.sol ====
|
||||
import "definition.sol";
|
||||
import "type.sol";
|
||||
|
||||
using {add as +} for Int global;
|
||||
using {unsub as -} for Int global;
|
||||
|
||||
==== Source: definition.sol ====
|
||||
import "type.sol";
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: type.sol ====
|
||||
type Int is int;
|
||||
|
||||
==== Source: use.sol ====
|
||||
import "type.sol";
|
||||
|
||||
contract C {
|
||||
function f() pure public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4117: (binding.sol:45-77): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 4117: (binding.sol:78-112): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 2271: (use.sol:72-97): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 4907: (use.sol:107-119): Built-in unary operator - cannot be applied to type Int. No matching user-defined operator found.
|
||||
@@ -0,0 +1,17 @@
|
||||
==== Source: s1.sol ====
|
||||
type Int is int;
|
||||
using {add as +} for Int global;
|
||||
using {unsub as -} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
|
||||
contract C {
|
||||
function f() pure public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
==== Source: s1.sol ====
|
||||
type Int is int;
|
||||
using {add as +} for Int;
|
||||
using {unsub as -} for Int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
|
||||
contract C {
|
||||
function f() pure public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (s1.sol:24-27): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (s1.sol:50-55): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 2271: (s2.sol:70-95): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 4907: (s2.sol:105-117): Built-in unary operator - cannot be applied to type Int. No matching user-defined operator found.
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
==== Source: s0.sol ====
|
||||
type Int is int;
|
||||
|
||||
==== Source: s1.sol ====
|
||||
import "s0.sol";
|
||||
using {add1 as +} for Int global;
|
||||
using {unsub1 as -} for Int global;
|
||||
|
||||
function add1(Int, Int) pure returns (Int) {}
|
||||
function unsub1(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s0.sol";
|
||||
using {add2 as +} for Int global;
|
||||
using {unsub2 as -} for Int global;
|
||||
|
||||
function add2(Int, Int) pure returns (Int) {}
|
||||
function unsub2(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: s3.sol ====
|
||||
import "s1.sol";
|
||||
import "s2.sol";
|
||||
contract C {
|
||||
function f() public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4117: (s1.sol:17-50): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 4117: (s1.sol:51-86): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 4117: (s2.sol:17-50): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 4117: (s2.sol:51-86): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 2271: (s3.sol:81-106): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 4907: (s3.sol:116-128): Built-in unary operator - cannot be applied to type Int. No matching user-defined operator found.
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
==== Source: s0.sol ====
|
||||
type Int is int;
|
||||
|
||||
==== Source: s1.sol ====
|
||||
import "s0.sol";
|
||||
using {add1 as +} for Int;
|
||||
using {unsub1 as -} for Int;
|
||||
|
||||
function add1(Int, Int) pure returns (Int) {}
|
||||
function unsub1(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s0.sol";
|
||||
using {add2 as +} for Int;
|
||||
using {unsub2 as -} for Int;
|
||||
|
||||
function add2(Int, Int) pure returns (Int) {}
|
||||
function unsub2(Int) pure returns (Int) {}
|
||||
|
||||
==== Source: s3.sol ====
|
||||
import "s1.sol";
|
||||
import "s2.sol";
|
||||
contract C {
|
||||
function f() public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (s1.sol:24-28): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (s1.sol:51-57): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (s2.sol:24-28): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (s2.sol:51-57): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 2271: (s3.sol:81-106): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 4907: (s3.sol:116-128): Built-in unary operator - cannot be applied to type Int. No matching user-defined operator found.
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
type B4 is bytes4;
|
||||
using {bitor as |, bitnot as ~} for B4 global;
|
||||
|
||||
function bitor(B4, B4) pure returns (B4) {}
|
||||
function bitnot(B4) pure returns (B4) {}
|
||||
|
||||
B4 constant X = B4.wrap(0x12345678) | B4.wrap(0xaabbccdd);
|
||||
|
||||
contract C {
|
||||
B4 constant Y = B4.wrap(0x12345678) | B4.wrap(0xaabbccdd);
|
||||
}
|
||||
|
||||
library L {
|
||||
B4 constant Z = ~B4.wrap(0x12345678);
|
||||
}
|
||||
|
||||
interface I {
|
||||
B4 constant W = ~B4.wrap(0x12345678);
|
||||
}
|
||||
// ----
|
||||
// TypeError 8349: (169-210): Initial value for constant variable has to be compile-time constant.
|
||||
// TypeError 8349: (246-287): Initial value for constant variable has to be compile-time constant.
|
||||
// TypeError 8349: (324-344): Initial value for constant variable has to be compile-time constant.
|
||||
// TypeError 8349: (383-403): Initial value for constant variable has to be compile-time constant.
|
||||
@@ -0,0 +1,14 @@
|
||||
type Int is int;
|
||||
using {add as +} for Int;
|
||||
using {unsub as -} for Int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
function f() pure {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (24-27): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (50-55): Operators can only be defined in a global 'using for' directive.
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
type Int is int16;
|
||||
|
||||
using {add as +} for Int global;
|
||||
|
||||
function add(Int, Int) returns (Int) {
|
||||
B b = new B();
|
||||
return b.f();
|
||||
}
|
||||
|
||||
contract B {
|
||||
Int s;
|
||||
function f() external returns (Int) {
|
||||
s = Int.wrap(3);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function test() public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7775: (27-30): Only pure free functions can be used to define operators.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
type Int is int16;
|
||||
using {add as +, unsub as -} for Int global;
|
||||
|
||||
IAdder constant ADDER = IAdder(address(0));
|
||||
|
||||
function add(Int x, Int y) pure returns (Int) {
|
||||
return ADDER.mul(x, y);
|
||||
}
|
||||
|
||||
function unsub(Int x) pure returns (Int) {
|
||||
return ADDER.inc(x);
|
||||
}
|
||||
|
||||
interface IAdder {
|
||||
function mul(Int, Int) external returns (Int);
|
||||
function inc(Int) external returns (Int);
|
||||
}
|
||||
// ----
|
||||
// TypeError 8961: (169-184): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (243-255): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
type Int is int16;
|
||||
using {add as +, unsub as -} for Int global;
|
||||
|
||||
IAdder constant ADDER = IAdder(address(0));
|
||||
|
||||
function add(Int x, Int y) pure returns (Int) {
|
||||
return ADDER.mul(x, y);
|
||||
}
|
||||
|
||||
function unsub(Int x) pure returns (Int) {
|
||||
return ADDER.inc(x);
|
||||
}
|
||||
|
||||
interface IAdder {
|
||||
function mul(Int, Int) external pure returns (Int);
|
||||
function inc(Int) external pure returns (Int);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
type Int is int16;
|
||||
using {add as +, unsub as -} for Int global;
|
||||
|
||||
IAdder constant ADDER = IAdder(address(0));
|
||||
|
||||
function add(Int x, Int y) pure returns (Int) {
|
||||
return ADDER.mul(x, y);
|
||||
}
|
||||
|
||||
function unsub(Int x) pure returns (Int) {
|
||||
return ADDER.inc(x);
|
||||
}
|
||||
|
||||
interface IAdder {
|
||||
function mul(Int, Int) external view returns (Int);
|
||||
function inc(Int) external view returns (Int);
|
||||
}
|
||||
// ----
|
||||
// TypeError 2527: (169-184): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (243-255): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
using {add as +, unsub as -} for U global;
|
||||
|
||||
type U is uint;
|
||||
|
||||
function add(U, U) pure returns (U) {}
|
||||
function unsub(U) pure returns (U) {}
|
||||
|
||||
contract C {
|
||||
function fromBool() public {
|
||||
U u;
|
||||
|
||||
u + true;
|
||||
true + u;
|
||||
-true;
|
||||
}
|
||||
|
||||
function fromUint() public {
|
||||
U u;
|
||||
uint32 u32;
|
||||
|
||||
u + u32;
|
||||
u32 + u;
|
||||
-u32;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 5653: (207-215): The type of the second operand of this user-defined binary operator + does not match the type of the first operand, which is U.
|
||||
// TypeError 2271: (225-233): Built-in binary operator + cannot be applied to types bool and U.
|
||||
// TypeError 4907: (243-248): Built-in unary operator - cannot be applied to type bool.
|
||||
// TypeError 5653: (332-339): The type of the second operand of this user-defined binary operator + does not match the type of the first operand, which is U.
|
||||
// TypeError 2271: (349-356): Built-in binary operator + cannot be applied to types uint32 and U.
|
||||
// TypeError 4907: (366-370): Built-in unary operator - cannot be applied to type uint32. Unary negation is only allowed for signed integers.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using {f as +} for uint global;
|
||||
using {f as +} for uint[2] global;
|
||||
using {f as +} for mapping(uint => uint) global;
|
||||
using {f as +} for function (uint) pure returns (uint) global;
|
||||
using {f as +} for string global;
|
||||
|
||||
function f(uint, uint) pure returns (uint) {}
|
||||
// ----
|
||||
// TypeError 8841: (0-31): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (7-8): Operators can only be implemented for user-defined value types.
|
||||
// TypeError 8841: (32-66): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (39-40): Operators can only be implemented for user-defined value types.
|
||||
// TypeError 8841: (67-115): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (74-75): Operators can only be implemented for user-defined value types.
|
||||
// TypeError 8841: (116-178): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (123-124): Operators can only be implemented for user-defined value types.
|
||||
// TypeError 8841: (179-212): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (186-187): Operators can only be implemented for user-defined value types.
|
||||
@@ -0,0 +1,13 @@
|
||||
using {fc as +} for C global;
|
||||
using {fa as +} for A global;
|
||||
|
||||
function fc(C, C) pure returns (C) {}
|
||||
function fa(A, A) pure returns (A) {}
|
||||
|
||||
contract C {}
|
||||
abstract contract A {}
|
||||
// ----
|
||||
// TypeError 8841: (0-29): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (7-9): Operators can only be implemented for user-defined value types.
|
||||
// TypeError 8841: (30-59): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (37-39): Operators can only be implemented for user-defined value types.
|
||||
@@ -0,0 +1,10 @@
|
||||
using {add as +} for E global;
|
||||
|
||||
enum E {
|
||||
E1,
|
||||
E2
|
||||
}
|
||||
|
||||
function add(E, E) pure returns (E) {}
|
||||
// ----
|
||||
// TypeError 5332: (7-10): Operators can only be implemented for user-defined value types.
|
||||
@@ -0,0 +1,10 @@
|
||||
using {add as +} for E global;
|
||||
|
||||
error E();
|
||||
|
||||
function add(E, E) pure returns (E) {
|
||||
return E.E1;
|
||||
}
|
||||
|
||||
// ----
|
||||
// TypeError 5172: (21-22): Name has to refer to a user-defined type.
|
||||
@@ -0,0 +1,10 @@
|
||||
using {add as +} for C.Event global;
|
||||
|
||||
contract C {
|
||||
event Event();
|
||||
}
|
||||
|
||||
function add(C.Event, C.Event) pure returns (C.Event) {}
|
||||
|
||||
// ----
|
||||
// TypeError 5172: (21-28): Name has to refer to a user-defined type.
|
||||
@@ -0,0 +1,8 @@
|
||||
using {f as +} for I global;
|
||||
|
||||
function f(I, I) pure returns (I) {}
|
||||
|
||||
interface I {}
|
||||
// ----
|
||||
// TypeError 8841: (0-28): Can only use "global" with user-defined types.
|
||||
// TypeError 5332: (7-8): Operators can only be implemented for user-defined value types.
|
||||
@@ -0,0 +1,6 @@
|
||||
using {f as +} for L global;
|
||||
|
||||
function f() pure {}
|
||||
library L {}
|
||||
// ----
|
||||
// TypeError 1130: (19-20): Invalid use of a library name.
|
||||
@@ -0,0 +1,9 @@
|
||||
using {add as +} for S global;
|
||||
|
||||
struct S {
|
||||
uint x;
|
||||
}
|
||||
|
||||
function add(S memory, S memory) pure returns (S memory) {}
|
||||
// ----
|
||||
// TypeError 5332: (7-10): Operators can only be implemented for user-defined value types.
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
type Int is int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
contract C {
|
||||
using {add as +} for *;
|
||||
}
|
||||
|
||||
contract D {
|
||||
using {add as +} for * global;
|
||||
}
|
||||
// ----
|
||||
// SyntaxError 3349: (81-104): The type has to be specified explicitly when attaching specific functions.
|
||||
// SyntaxError 3349: (125-155): The type has to be specified explicitly when attaching specific functions.
|
||||
// SyntaxError 2854: (125-155): Can only globally attach functions to specific types.
|
||||
// SyntaxError 3367: (125-155): "global" can only be used at file level.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
using {add as +} for * global;
|
||||
|
||||
function add(int, int) returns (int) {}
|
||||
// ----
|
||||
// SyntaxError 8118: (0-30): The type has to be specified explicitly at file level (cannot use '*').
|
||||
// SyntaxError 2854: (0-30): Can only globally attach functions to specific types.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
type Int is uint;
|
||||
using {f} for Int;
|
||||
|
||||
Int constant v;
|
||||
using {v.f as +} for Int global;
|
||||
|
||||
function f(Int) pure returns (Int) {}
|
||||
// ----
|
||||
// DeclarationError 9589: (61-64): Identifier is not a function name or not unique.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
type Int is int16;
|
||||
|
||||
using {abi.encode as +} for Int global;
|
||||
|
||||
function f(Int, Int) pure returns (Int) {}
|
||||
|
||||
// ----
|
||||
// DeclarationError 9589: (27-37): Identifier is not a function name or not unique.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
type Int is int16;
|
||||
|
||||
using {keccak256 as +} for Int global;
|
||||
// ----
|
||||
// TypeError 8187: (27-36): Expected function name.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
type Int is int16;
|
||||
|
||||
using {revert as +} for Int global;
|
||||
// ----
|
||||
// DeclarationError 9589: (27-33): Identifier is not a function name or not unique.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
type Int is int;
|
||||
|
||||
contract C {
|
||||
using {add as +} for 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
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
type Int is int;
|
||||
|
||||
using {C.add as +} for Int global;
|
||||
|
||||
contract C {
|
||||
function add(Int, Int) public pure returns (Int) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4167: (25-30): Only file-level functions and library functions can be attached to a type in a "using" statement
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
type Int is int16;
|
||||
|
||||
using {IntError as +} for Int global;
|
||||
|
||||
error IntError(Int a, Int b);
|
||||
// ----
|
||||
// TypeError 8187: (27-35): Expected function name.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
type Int is int16;
|
||||
|
||||
using {C.IntEvent as +} for Int global;
|
||||
|
||||
contract C {
|
||||
event IntEvent(Int a, Int b);
|
||||
}
|
||||
// ----
|
||||
// TypeError 8187: (27-37): Expected function name.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
type Int is int8;
|
||||
|
||||
contract C {
|
||||
function(Int, Int) external pure returns (Int) ptr;
|
||||
using {ptr as +} for Int;
|
||||
}
|
||||
// ----
|
||||
// TypeError 8187: (99-102): Expected function name.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
type Int is int16;
|
||||
|
||||
using {keccak256 as +} for Int global;
|
||||
|
||||
function keccak256(Int, Int) pure returns (Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// Warning 2319: (60-135): This declaration shadows a builtin symbol.
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
type Int is int16;
|
||||
|
||||
using {L as +} for Int global;
|
||||
|
||||
library L {}
|
||||
// ----
|
||||
// TypeError 8187: (27-28): Expected function name.
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
==== Source: external.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) external pure returns (Int) {}
|
||||
function unaryOperator(Int) external pure returns (Int) {}
|
||||
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
contract C {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
library X {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
==== Source: internal.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) internal pure returns (Int) {}
|
||||
function unaryOperator(Int) internal pure returns (Int) {}
|
||||
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
contract C {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
library X {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
==== Source: private.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) private pure returns (Int) {}
|
||||
function unaryOperator(Int) private pure returns (Int) {}
|
||||
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
==== Source: public.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) public pure returns (Int) {}
|
||||
function unaryOperator(Int) public pure returns (Int) {}
|
||||
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
contract C {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
library X {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (external.sol:177-193): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (external.sol:177-193): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (external.sol:220-235): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (external.sol:220-235): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (external.sol:278-294): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (external.sol:278-294): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (external.sol:321-336): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (external.sol:321-336): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (external.sol:378-394): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (external.sol:378-394): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (external.sol:421-436): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (external.sol:421-436): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (internal.sol:177-193): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (internal.sol:177-193): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (internal.sol:220-235): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (internal.sol:220-235): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (internal.sol:278-294): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (internal.sol:278-294): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (internal.sol:321-336): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (internal.sol:321-336): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (internal.sol:378-394): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (internal.sol:378-394): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (internal.sol:421-436): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (internal.sol:421-436): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (private.sol:175-191): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (private.sol:175-191): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (private.sol:218-233): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (private.sol:218-233): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (public.sol:173-189): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (public.sol:173-189): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (public.sol:216-231): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (public.sol:216-231): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (public.sol:274-290): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (public.sol:274-290): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (public.sol:317-332): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (public.sol:317-332): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (public.sol:374-390): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (public.sol:374-390): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (public.sol:417-432): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (public.sol:417-432): Only pure free functions can be used to define operators.
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
==== Source: external.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) external pure returns (Int) {}
|
||||
function unaryOperator(Int) external pure returns (Int) {}
|
||||
}
|
||||
|
||||
using {L.binaryOperator as +} for Int global;
|
||||
using {L.unaryOperator as -} for Int global;
|
||||
|
||||
==== Source: internal.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) internal pure returns (Int) {}
|
||||
function unaryOperator(Int) internal pure returns (Int) {}
|
||||
}
|
||||
|
||||
using {L.binaryOperator as +} for Int global;
|
||||
using {L.unaryOperator as -} for Int global;
|
||||
|
||||
==== Source: public.sol ====
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) public pure returns (Int) {}
|
||||
function unaryOperator(Int) public pure returns (Int) {}
|
||||
}
|
||||
|
||||
using {L.binaryOperator as +} for Int global;
|
||||
using {L.unaryOperator as -} for Int global;
|
||||
// ----
|
||||
// TypeError 7775: (external.sol:175-191): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (external.sol:221-236): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (internal.sol:175-191): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (internal.sol:221-236): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (public.sol:171-187): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (public.sol:217-232): Only pure free functions can be used to define operators.
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
type Int is int128;
|
||||
|
||||
library L {
|
||||
function binaryOperator(Int, Int) private pure returns (Int) {}
|
||||
function unaryOperator(Int) private pure returns (Int) {}
|
||||
}
|
||||
|
||||
using {L.binaryOperator as +} for Int global;
|
||||
using {L.unaryOperator as -} for Int global;
|
||||
|
||||
contract C {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
|
||||
library X {
|
||||
using {L.binaryOperator as *} for Int;
|
||||
using {L.unaryOperator as ~} for Int;
|
||||
}
|
||||
// ----
|
||||
// TypeError 6772: (173-189): Function "L.binaryOperator" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 7775: (173-189): Only pure free functions can be used to define operators.
|
||||
// TypeError 6772: (219-234): Function "L.unaryOperator" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 7775: (219-234): Only pure free functions can be used to define operators.
|
||||
// TypeError 6772: (282-298): Function "L.binaryOperator" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 3320: (282-298): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (282-298): Only pure free functions can be used to define operators.
|
||||
// TypeError 6772: (325-340): Function "L.unaryOperator" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 3320: (325-340): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (325-340): Only pure free functions can be used to define operators.
|
||||
// TypeError 6772: (382-398): Function "L.binaryOperator" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 3320: (382-398): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (382-398): Only pure free functions can be used to define operators.
|
||||
// TypeError 6772: (425-440): Function "L.unaryOperator" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 3320: (425-440): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (425-440): Only pure free functions can be used to define operators.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using {add as +, sub as -, mul as *} for A global;
|
||||
|
||||
function add(A, A) view returns (A) {}
|
||||
function sub(A, A) returns (A) {}
|
||||
function mul(A, A) payable returns (A) {}
|
||||
|
||||
type A is address payable;
|
||||
// ----
|
||||
// TypeError 7775: (7-10): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (17-20): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (27-30): Only pure free functions can be used to define operators.
|
||||
// TypeError 9559: (125-166): Free functions cannot be payable.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// This should point out all 3 errors, rather than give up after the first one.
|
||||
using {add as +} for address;
|
||||
|
||||
function add(address, address) view returns (address) {}
|
||||
// ----
|
||||
// TypeError 3320: (87-90): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (87-90): Only pure free functions can be used to define operators.
|
||||
// TypeError 5332: (87-90): Operators can only be implemented for user-defined value types.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using {add as +} for A global;
|
||||
using {add as +} for AP global;
|
||||
|
||||
function add(A, A) pure returns (A) {}
|
||||
function add(AP, AP) pure returns (AP) {}
|
||||
|
||||
type A is address;
|
||||
type AP is address payable;
|
||||
// ----
|
||||
// DeclarationError 9589: (7-10): Identifier is not a function name or not unique.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using {L.add as +} for A global;
|
||||
using {L.add as +} for AP global;
|
||||
|
||||
library L {
|
||||
function add(A, A) private pure returns (A) {}
|
||||
function add(AP, AP) internal pure returns (AP) {}
|
||||
}
|
||||
|
||||
type A is address;
|
||||
type AP is address payable;
|
||||
// ----
|
||||
// DeclarationError 9589: (7-12): Identifier is not a function name or not unique.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
type B32 is bytes32;
|
||||
|
||||
library L {
|
||||
function publicOperator(B32, B32) public pure returns (B32) {}
|
||||
}
|
||||
|
||||
using {publicOperator as +} for B32 global;
|
||||
// ----
|
||||
// DeclarationError 9589: (111-125): Identifier is not a function name or not unique.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
type B32 is bytes32;
|
||||
|
||||
library L {
|
||||
using {externalOperator as +} for B32;
|
||||
using {publicOperator as -} for B32;
|
||||
using {internalOperator as *} for B32;
|
||||
using {privateOperator as /} for B32;
|
||||
|
||||
function externalOperator(B32, B32) external pure returns (B32) {}
|
||||
function publicOperator(B32, B32) public pure returns (B32) {}
|
||||
function internalOperator(B32, B32) internal pure returns (B32) {}
|
||||
function privateOperator(B32, B32) private pure returns (B32) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (45-61): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (45-61): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (88-102): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (88-102): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (129-145): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (129-145): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (172-187): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (172-187): Only pure free functions can be used to define operators.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
==== Source: Int.sol ====
|
||||
type Int is int;
|
||||
|
||||
using {add as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
==== Source: test.sol ====
|
||||
import "Int.sol";
|
||||
|
||||
using {anotherAdd as +} for Int;
|
||||
|
||||
function anotherAdd(Int, Int) pure returns (Int) {}
|
||||
|
||||
function test() pure returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (test.sol:26-36): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 4705: (test.sol:26-36): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
type Int is int;
|
||||
|
||||
using {add as +} for Int global;
|
||||
using {add2 as +} for Int;
|
||||
using {unsub as -} for Int global;
|
||||
using {unsub2 as -} for Int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function add2(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
function unsub2(Int) pure returns (Int) {}
|
||||
|
||||
function testBinary() pure returns (Int) {
|
||||
return Int.wrap(1) + Int.wrap(2);
|
||||
}
|
||||
|
||||
function testUnary() pure returns (Int) {
|
||||
return -Int.wrap(2);
|
||||
}
|
||||
// ----
|
||||
// TypeError 4705: (25-28): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 3320: (58-62): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 4705: (58-62): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 4705: (85-90): User-defined unary operator - has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 3320: (120-126): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 4705: (120-126): User-defined unary operator - has more than one definition matching the operand type visible in the current scope.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
==== Source: Int.sol ====
|
||||
type Int is int;
|
||||
|
||||
using {add as +} for Int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
==== Source: test.sol ====
|
||||
import "Int.sol";
|
||||
|
||||
using {anotherAdd as +} for Int global;
|
||||
|
||||
function anotherAdd(Int, Int) pure returns (Int) {}
|
||||
|
||||
function test() pure returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (Int.sol:25-28): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 4117: (test.sol:19-58): Can only use "global" with types defined in the same source unit at file level.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
type Int is uint128;
|
||||
|
||||
using {add as +, sub as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function sub(Int, Int) pure returns (Int) {}
|
||||
|
||||
function test() {
|
||||
Int.wrap(0) + Int.wrap(1);
|
||||
}
|
||||
// ----
|
||||
// TypeError 4705: (29-32): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 4705: (39-42): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
type Int is uint128;
|
||||
|
||||
// Still an error, even if the operator is not actually used
|
||||
using {add1 as +, add2 as +} for Int global;
|
||||
using {unsub1 as -, unsub2 as -} for Int global;
|
||||
|
||||
function add1(Int, Int) pure returns (Int) {}
|
||||
function add2(Int, Int) pure returns (Int) {}
|
||||
function unsub1(Int) pure returns (Int) {}
|
||||
function unsub2(Int) pure returns (Int) {}
|
||||
// ----
|
||||
// TypeError 4705: (90-94): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 4705: (101-105): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 4705: (135-141): User-defined unary operator - has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 4705: (148-154): User-defined unary operator - has more than one definition matching the operand type visible in the current scope.
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
type Int is int;
|
||||
|
||||
using {add as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function another_add(Int, Int) pure returns (Int) {}
|
||||
|
||||
contract B {
|
||||
using {another_add as +} for Int;
|
||||
|
||||
function f() public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
contract C is B {
|
||||
function g() public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (175-186): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 4705: (175-186): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
type Int is int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function unsub(Int) pure returns (Int) {}
|
||||
|
||||
using {add as +, unsub as -} for Int global;
|
||||
|
||||
contract C {
|
||||
using {add as +, unsub as -} for Int;
|
||||
}
|
||||
|
||||
library X {
|
||||
using {add as +, unsub as -} for Int;
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (176-179): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (186-191): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (233-236): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (243-248): Operators can only be defined in a global 'using for' directive.
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
type Int is int;
|
||||
|
||||
library L {
|
||||
using {add as +, unsub as -} for Int;
|
||||
using {L.add as +, L.unsub as -} for Int;
|
||||
|
||||
function add(Int, Int) internal pure returns (Int) {}
|
||||
function unsub(Int) internal pure returns (Int) {}
|
||||
}
|
||||
|
||||
using {L.add as +, L.unsub as -} for Int global;
|
||||
|
||||
contract C {
|
||||
using {L.add as +, L.unsub as -} for Int;
|
||||
}
|
||||
|
||||
library X {
|
||||
using {L.add as +, L.unsub as -} for Int;
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (41-44): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (41-44): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (51-56): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (51-56): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (83-88): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (83-88): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (95-102): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (95-102): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (242-247): Only pure free functions can be used to define operators.
|
||||
// TypeError 7775: (254-261): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (309-314): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (309-314): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (321-328): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (321-328): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (370-375): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (370-375): Only pure free functions can be used to define operators.
|
||||
// TypeError 3320: (382-389): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 7775: (382-389): Only pure free functions can be used to define operators.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
type Int is int32;
|
||||
|
||||
using {add as +, add as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns(Int) {}
|
||||
|
||||
function f(int32 a, int32 b) pure {
|
||||
Int.wrap(a) + Int.wrap(b);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
type Int is int32;
|
||||
|
||||
using {add as +} for Int global;
|
||||
using {add as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns(Int) {}
|
||||
|
||||
function f(int32 a, int32 b) pure {
|
||||
Int.wrap(a) + Int.wrap(b);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
type Int is uint128;
|
||||
|
||||
using {add as +, add128 as +} for Int global;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function add128(Int, int128) pure returns (Int) {}
|
||||
|
||||
function test() {
|
||||
Int.wrap(0) + Int.wrap(1);
|
||||
}
|
||||
// ----
|
||||
// TypeError 4705: (29-32): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
// TypeError 1884: (129-142): Wrong parameters in operator definition. The function "add128" needs to have two parameters of type Int and the same data location to be used for the operator +.
|
||||
// TypeError 4705: (39-45): User-defined binary operator + has more than one definition matching the operand type visible in the current scope.
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
using {as -} for uint global;
|
||||
// ----
|
||||
// ParserError 2314: (7-9): Expected identifier but got 'as'
|
||||
@@ -0,0 +1,3 @@
|
||||
using f as - for uint global;
|
||||
// ----
|
||||
// ParserError 2314: (8-10): Expected 'for' but got 'as'
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using {
|
||||
f as new,
|
||||
f as delete,
|
||||
f as **,
|
||||
f as <<,
|
||||
f as >>,
|
||||
f as &&,
|
||||
f as ||,
|
||||
f as !,
|
||||
f as =,
|
||||
f as |=,
|
||||
f as ^=,
|
||||
f as &=,
|
||||
f as <<=,
|
||||
f as >>=,
|
||||
f as +=,
|
||||
f as -=,
|
||||
f as *=,
|
||||
f as /=,
|
||||
f as %=,
|
||||
f as ++,
|
||||
f as --
|
||||
} for int256 global;
|
||||
// ----
|
||||
// ParserError 4403: (17-20): Not a user-definable operator: new. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (31-37): Not a user-definable operator: delete. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (48-50): Not a user-definable operator: **. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (61-63): Not a user-definable operator: <<. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (74-76): Not a user-definable operator: >>. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (87-89): Not a user-definable operator: &&. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (100-102): Not a user-definable operator: ||. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (113-114): Not a user-definable operator: !. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (125-126): Not a user-definable operator: =. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (137-139): Not a user-definable operator: |=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (150-152): Not a user-definable operator: ^=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (163-165): Not a user-definable operator: &=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (176-179): Not a user-definable operator: <<=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (190-193): Not a user-definable operator: >>=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (204-206): Not a user-definable operator: +=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (217-219): Not a user-definable operator: -=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (230-232): Not a user-definable operator: *=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (243-245): Not a user-definable operator: /=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (256-258): Not a user-definable operator: %=. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (269-271): Not a user-definable operator: ++. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (282-284): Not a user-definable operator: --. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using {
|
||||
f as x,
|
||||
f as operator,
|
||||
f as as,
|
||||
f as 123,
|
||||
f as ()
|
||||
} for int256 global;
|
||||
// ----
|
||||
// ParserError 4403: (17-18): Not a user-definable operator: x. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (29-37): Not a user-definable operator: operator. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (48-50): Not a user-definable operator: as. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (61-64): Not a user-definable operator: 123. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 4403: (75-76): Not a user-definable operator: (. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 2314: (76-77): Expected '}' but got ')'
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
using {f as} for uint global;
|
||||
// ----
|
||||
// ParserError 4403: (11-12): Not a user-definable operator: }. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
// ParserError 2314: (13-16): Expected '}' but got 'for'
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
using {f as as} for uint global;
|
||||
// ----
|
||||
// ParserError 4403: (12-14): Not a user-definable operator: as. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
|
||||
@@ -0,0 +1,33 @@
|
||||
type Int is int256;
|
||||
|
||||
using {
|
||||
add as +,
|
||||
div as /,
|
||||
unsub as -,
|
||||
bitnot as ~,
|
||||
gt as >,
|
||||
lt as <
|
||||
} for Int global;
|
||||
|
||||
function add(Int x, Int y) pure returns (int256) {}
|
||||
function div(Int x, Int y) pure {}
|
||||
function unsub(Int) pure returns (Int, Int) {}
|
||||
function bitnot(Int) pure returns (int256) {}
|
||||
function gt(Int, Int) pure returns (Int) {}
|
||||
function lt(Int, Int) pure returns (bool, Int) {}
|
||||
|
||||
function f() pure {
|
||||
Int.wrap(0) + Int.wrap(1);
|
||||
Int.wrap(0) / Int.wrap(0);
|
||||
-Int.wrap(0);
|
||||
~Int.wrap(0);
|
||||
Int.wrap(0) < Int.wrap(0);
|
||||
Int.wrap(0) > Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// TypeError 7743: (174-182): Wrong return parameters in operator definition. The function "add" needs to return exactly one value of type Int to be used for the operator +.
|
||||
// TypeError 7743: (218-218): Wrong return parameters in operator definition. The function "div" needs to return exactly one value of type Int to be used for the operator /.
|
||||
// TypeError 7743: (254-264): Wrong return parameters in operator definition. The function "unsub" needs to return exactly one value of type Int to be used for the operator -.
|
||||
// TypeError 7743: (302-310): Wrong return parameters in operator definition. The function "bitnot" needs to return exactly one value of type Int to be used for the operator ~.
|
||||
// TypeError 7743: (349-354): Wrong return parameters in operator definition. The function "gt" needs to return exactly one value of type bool to be used for the operator >.
|
||||
// TypeError 7743: (393-404): Wrong return parameters in operator definition. The function "lt" needs to return exactly one value of type bool to be used for the operator <.
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
type Int is int256;
|
||||
|
||||
using {
|
||||
add as +,
|
||||
sub as -,
|
||||
div as /
|
||||
} for Int global;
|
||||
|
||||
function add(Int) pure returns (Int) {}
|
||||
function sub(Int, Int, Int) pure returns (Int) {}
|
||||
function div(int256, int256) pure returns (Int) {}
|
||||
|
||||
function f() pure {
|
||||
Int.wrap(0) + Int.wrap(1);
|
||||
Int.wrap(0) - Int.wrap(0);
|
||||
Int.wrap(0) / Int.wrap(0);
|
||||
}
|
||||
|
||||
// ----
|
||||
// TypeError 1884: (101-106): Wrong parameters in operator definition. The function "add" needs to have two parameters of type Int and the same data location to be used for the operator +.
|
||||
// TypeError 1884: (141-156): Wrong parameters in operator definition. The function "sub" needs to have one or two parameters of type Int and the same data location to be used for the operator -.
|
||||
// TypeError 1884: (191-207): Wrong parameters in operator definition. The function "div" needs to have one or two parameters of type Int and the same data location to be used for the operator /.
|
||||
// TypeError 7743: (221-226): Wrong return parameters in operator definition. The function "div" needs to return a value of the same type and data location as its parameters to be used for the operator /.
|
||||
// TypeError 2271: (255-280): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 2271: (286-311): Built-in binary operator - cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
// TypeError 2271: (317-342): Built-in binary operator / cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
type Int is int;
|
||||
|
||||
using {
|
||||
f as +
|
||||
} for Int global;
|
||||
|
||||
function f() returns (Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// TypeError 4731: (30-31): The function "f" does not have any parameters, and therefore cannot be attached to the type "Int".
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
type Int is int;
|
||||
|
||||
using {
|
||||
f as ~
|
||||
} for Int global;
|
||||
|
||||
function f() returns (Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
// ----
|
||||
// TypeError 4731: (30-31): The function "f" does not have any parameters, and therefore cannot be attached to the type "Int".
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
type Int is int128;
|
||||
|
||||
using {
|
||||
add as +,
|
||||
sub as -,
|
||||
mul as *,
|
||||
div as /
|
||||
} for Int global;
|
||||
|
||||
function add(Int, int128) pure returns (Int) {}
|
||||
function sub(int128, Int) pure returns (int128) {}
|
||||
function mul(int128, int256) pure returns (Int) {}
|
||||
function div(Int, Int) pure returns (int256) {}
|
||||
// ----
|
||||
// TypeError 1884: (115-128): Wrong parameters in operator definition. The function "add" needs to have two parameters of type Int and the same data location to be used for the operator +.
|
||||
// TypeError 1884: (163-176): Wrong parameters in operator definition. The function "sub" needs to have one or two parameters of type Int and the same data location to be used for the operator -.
|
||||
// TypeError 7743: (190-198): Wrong return parameters in operator definition. The function "sub" needs to return exactly one value of type Int to be used for the operator -.
|
||||
// TypeError 1884: (214-230): Wrong parameters in operator definition. The function "mul" needs to have two parameters of type Int and the same data location to be used for the operator *.
|
||||
// TypeError 7743: (244-249): Wrong return parameters in operator definition. The function "mul" needs to return a value of the same type and data location as its parameters to be used for the operator *.
|
||||
// TypeError 7743: (289-297): Wrong return parameters in operator definition. The function "div" needs to return exactly one value of type Int to be used for the operator /.
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
type Int is int128;
|
||||
|
||||
using {bitnot as ~} for Int global;
|
||||
|
||||
function bitnot(Int, Int) pure returns (Int) {}
|
||||
|
||||
contract C {
|
||||
function test() public pure {
|
||||
~Int.wrap(1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1884: (73-83): Wrong parameters in operator definition. The function "bitnot" needs to have exactly one parameter of type Int to be used for the operator ~.
|
||||
// TypeError 4907: (162-174): Built-in unary operator ~ cannot be applied to type Int. No matching user-defined operator found.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
type AP is address payable;
|
||||
|
||||
function sub(AP, AP) pure returns (AP) {}
|
||||
function unsub(AP) pure returns (AP) {}
|
||||
|
||||
function attachedPure(AP, uint, address) pure {}
|
||||
function attachedView(AP) view {}
|
||||
function attached(AP, function(AP)) {}
|
||||
|
||||
using {sub as -, attachedPure, attachedView, unsub as -, attached} for AP global;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
library L {
|
||||
type FixedBytes is bytes10;
|
||||
}
|
||||
|
||||
function add(L.FixedBytes, L.FixedBytes) pure returns (L.FixedBytes) {}
|
||||
function unsub(L.FixedBytes, L.FixedBytes) pure returns (L.FixedBytes) {}
|
||||
|
||||
library LX {
|
||||
using {add as +, unsub as -} for L.FixedBytes;
|
||||
}
|
||||
|
||||
contract CX {
|
||||
using {add as +, unsub as -} for L.FixedBytes;
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (218-221): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (228-233): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (286-289): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (296-301): Operators can only be defined in a global 'using for' directive.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
type Int is int16;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
contract C {
|
||||
using {add as +} for Int global;
|
||||
|
||||
function test() pure public {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError 3367: (83-115): "global" can only be used at file level.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
==== Source: s1.sol ====
|
||||
type Int is int;
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
|
||||
function bitnot(Int) pure returns (Int) {}
|
||||
|
||||
contract C {
|
||||
using {bitnot as ~} for Int global;
|
||||
}
|
||||
// ----
|
||||
// SyntaxError 3367: (s2.sol:79-114): "global" can only be used at file level.
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
type Int is int128;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
function another_add(Int, Int) pure returns (Int) {}
|
||||
|
||||
contract B {
|
||||
using {add as +} for Int;
|
||||
|
||||
function f() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
contract C is B {
|
||||
using {another_add as +} for Int;
|
||||
|
||||
function g() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
contract D is B {
|
||||
function h() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (144-147): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (289-300): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 2271: (491-516): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
type Int is int;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {}
|
||||
|
||||
interface I {
|
||||
using {add as +} for Int;
|
||||
}
|
||||
// ----
|
||||
// SyntaxError 9088: (82-107): The "using for" directive is not allowed inside interfaces.
|
||||
// TypeError 3320: (89-92): Operators can only be defined in a global 'using for' directive.
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
library L {
|
||||
type FixedBytes is bytes1;
|
||||
}
|
||||
|
||||
contract C {
|
||||
type FixedBytes is bytes2;
|
||||
}
|
||||
|
||||
interface I {
|
||||
type FixedBytes is bytes3;
|
||||
}
|
||||
|
||||
function addL(L.FixedBytes, L.FixedBytes) pure returns (L.FixedBytes) {}
|
||||
function addC(C.FixedBytes, C.FixedBytes) pure returns (C.FixedBytes) {}
|
||||
function addI(I.FixedBytes, I.FixedBytes) pure returns (I.FixedBytes) {}
|
||||
|
||||
function unsubL(L.FixedBytes) pure returns (L.FixedBytes) {}
|
||||
function unsubC(C.FixedBytes) pure returns (C.FixedBytes) {}
|
||||
function unsubI(I.FixedBytes) pure returns (I.FixedBytes) {}
|
||||
|
||||
using {addL as +, unsubL as -} for L.FixedBytes global;
|
||||
using {addC as +, unsubC as -} for C.FixedBytes global;
|
||||
using {addI as +, unsubI as -} for I.FixedBytes global;
|
||||
// ----
|
||||
// TypeError 4117: (545-600): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 4117: (601-656): Can only use "global" with types defined in the same source unit at file level.
|
||||
// TypeError 4117: (657-712): Can only use "global" with types defined in the same source unit at file level.
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
library L {
|
||||
type FixedBytes is bytes1;
|
||||
}
|
||||
|
||||
contract C {
|
||||
type FixedBytes is bytes2;
|
||||
}
|
||||
|
||||
interface I {
|
||||
type FixedBytes is bytes3;
|
||||
}
|
||||
|
||||
function addL(L.FixedBytes, L.FixedBytes) pure returns (L.FixedBytes) {}
|
||||
function addC(C.FixedBytes, C.FixedBytes) pure returns (C.FixedBytes) {}
|
||||
function addI(I.FixedBytes, I.FixedBytes) pure returns (I.FixedBytes) {}
|
||||
|
||||
function unsubL(L.FixedBytes) pure returns (L.FixedBytes) {}
|
||||
function unsubC(C.FixedBytes) pure returns (C.FixedBytes) {}
|
||||
function unsubI(I.FixedBytes) pure returns (I.FixedBytes) {}
|
||||
|
||||
using {addL as +, unsubL as -} for L.FixedBytes;
|
||||
using {addC as +, unsubC as -} for C.FixedBytes;
|
||||
using {addI as +, unsubI as -} for I.FixedBytes;
|
||||
// ----
|
||||
// TypeError 3320: (552-556): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (563-569): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (601-605): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (612-618): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (650-654): Operators can only be defined in a global 'using for' directive.
|
||||
// TypeError 3320: (661-667): Operators can only be defined in a global 'using for' directive.
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
==== Source: s1.sol ====
|
||||
type Int is int;
|
||||
|
||||
using {add as +} for Int global;
|
||||
using {add as +} for Int;
|
||||
|
||||
function add(Int a, Int b) pure returns (Int) {}
|
||||
function test_add() pure returns (Int) {}
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
|
||||
contract C2 {
|
||||
function test1() pure public returns (Int) {
|
||||
return test_add();
|
||||
}
|
||||
|
||||
function test2() pure public returns (Int) {
|
||||
return Int.wrap(3) + Int.wrap(4);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (s1.sol:58-61): Operators can only be defined in a global 'using for' directive.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
==== Source: s1.sol ====
|
||||
type Int is int;
|
||||
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
|
||||
function bitnot(Int) pure returns (Int) {}
|
||||
|
||||
using {bitnot as ~} for Int global;
|
||||
// ----
|
||||
// TypeError 4117: (s2.sol:62-97): Can only use "global" with types defined in the same source unit at file level.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
type Int is int16;
|
||||
|
||||
using {unsub as -} for Int global;
|
||||
using {sub as -} for Int;
|
||||
|
||||
function sub(Int a, Int b) pure returns (Int) {}
|
||||
|
||||
function unsub(Int a) pure returns (Int) {}
|
||||
|
||||
contract C {
|
||||
function test_sub() public pure returns (Int) {
|
||||
return Int.wrap(7) - Int.wrap(2);
|
||||
}
|
||||
|
||||
function test_unsub() public pure returns (Int) {
|
||||
return -Int.wrap(4);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3320: (62-65): Operators can only be defined in a global 'using for' directive.
|
||||
Reference in New Issue
Block a user