Updates after code review

This commit is contained in:
wechman
2022-09-28 13:09:16 +02:00
parent 7b81a65bc6
commit cdbc06419f
25 changed files with 254 additions and 31 deletions
@@ -0,0 +1,16 @@
type Int is int16;
function add(Int, Int) pure returns (Int) {
return Int.wrap(0);
}
contract C {
using {add as +} for Int global;
function test() pure public {
Int.wrap(0) + Int.wrap(0);
}
}
// ----
// SyntaxError 3367: (108-140): "global" can only be used at file level.
@@ -0,0 +1,20 @@
==== Source: s1.sol ====
type Int is int;
using {add as +} for Int global;
using {another_add as +} for Int;
function add(Int, Int) pure returns (Int) {
return Int.wrap(0);
}
function another_add(Int, Int) pure returns (Int) {
return Int.wrap(0);
}
function test() pure returns (Int) {
return Int.wrap(1) + Int.wrap(2);
}
// ----
// TypeError 2271: (s1.sol:284-309): Binary operator + not compatible with types Int and Int. Multiple user-defined functions provided for this operator.
@@ -0,0 +1,15 @@
type Int is int;
using {unsub as -} for Int global;
using {another_unsub as -} for Int;
function unsub(Int) pure returns (Int) {}
function another_unsub(Int) pure returns (Int) {}
function test() pure returns (Int) {
return -Int.wrap(2);
}
// ----
// TypeError 4907: (232-244): Built-in unary operator - cannot be applied to type Int. Multiple user-defined functions provided for this operator.
@@ -1,15 +1,23 @@
==== Source: s1.sol ====
type Int is int;
using {add as +} for Int global;
using {sub as -} for Int;
function add(Int, Int) pure returns (Int) {
return Int.wrap(3);
}
function sub(Int, Int) pure returns (Int) {
return Int.wrap(4);
}
==== Source: s2.sol ====
import "s1.sol";
contract C {
function f() pure public {
Int.wrap(0) + Int.wrap(0);
Int.wrap(0) - Int.wrap(0);
}
}
// ----
// TypeError 2271: (s2.sol:104-129): Binary operator - not compatible with types Int and Int. No matching user-defined operator found.