solidity/test/libsolidity/semanticTests/literalSuffixes/operators_on_suffixed_booleans.sol
2023-05-17 16:55:14 +02:00

27 lines
628 B
Solidity

type Bool is bool;
using {bitor as |, bitand as &, bitnot as ~} for Bool global;
function bitor(Bool x, Bool y) pure returns (Bool) {
return Bool.wrap(Bool.unwrap(x) || Bool.unwrap(y));
}
function bitand(Bool x, Bool y) pure returns (Bool) {
return Bool.wrap(Bool.unwrap(x) && Bool.unwrap(y));
}
function bitnot(Bool x) pure returns (Bool) {
return Bool.wrap(!Bool.unwrap(x));
}
function b(bool x) pure suffix returns (Bool) {
return Bool.wrap(x);
}
contract C {
function test() public pure returns (Bool) {
return ~ ~ ~(false b | true b & ~false b) & true b;
}
}
// ----
// test() -> false