solidity/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_shortening.sol
2020-03-19 14:42:25 +01:00

16 lines
377 B
Solidity

contract C {
function f() public pure returns (bytes32 r) {
bytes4 x = 0xffffffff;
bytes2 y = bytes2(x);
assembly {
r := y
}
// At this point, r and y both store four bytes, but
// y is properly cleaned before the equality check
require(y == bytes2(0xffff));
}
}
// ----
// f() -> "\xff\xff\xff\xff"