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:
+17
@@ -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.
|
||||
Reference in New Issue
Block a user