mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Updates after code review
This commit is contained in:
+16
@@ -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.
|
||||
+20
@@ -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.
|
||||
+15
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user