User-defined operators: Tests

This commit is contained in:
wechman
2023-02-22 00:40:03 +01:00
committed by Kamil Śliwak
parent 5b5e853ea0
commit aba5ac5e2a
114 changed files with 3956 additions and 1 deletions
@@ -0,0 +1,17 @@
type X is uint24;
type Y is uint16;
using {addX as +} for X global;
using {addY as +} for Y global;
function addX(X, X) pure returns (X) {}
function addY(Y, Y) pure returns (Y) { revert(); }
contract C {
function f() public pure {
X.wrap(1) + X.wrap(Y.unwrap(Y.wrap(2) + Y.wrap(3)));
X.wrap(4) + X.wrap(5); // Unreachable
}
}
// ----
// Warning 5740: (307-328): Unreachable code.
@@ -0,0 +1,17 @@
type X is uint24;
type Y is uint16;
using {unsubX as -} for X global;
using {unsubY as -} for Y global;
function unsubX(X) pure returns (X) {}
function unsubY(Y) pure returns (Y) { revert(); }
contract C {
function f() public pure {
-X.wrap(Y.unwrap(-Y.wrap(1)));
-X.wrap(Y.unwrap(Y.wrap(2))); // Unreachable
}
}
// ----
// Warning 5740: (287-315): Unreachable code.