solidity/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_shortening.sol
2020-05-05 17:23:41 +02:00

17 lines
407 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));
}
}
// ====
// compileViaYul: also
// ----
// f() -> "\xff\xff\xff\xff"