solidity/test/libsolidity/semanticTests/various/address_code.sol
Daniel Kirchner 44da8507b1 Change default EVM version to Shanghai.
Co-authored-by: Rodrigo Q. Saramago <rodrigoqsaramago@gmail.com>
2023-05-08 16:34:23 +02:00

26 lines
742 B
Solidity

contract C {
bytes public initCode;
constructor() {
// This should catch problems, but lets also test the case the optimiser is buggy.
assert(address(this).code.length == 0);
initCode = address(this).code;
}
// To avoid dependency on exact length.
function f() public view returns (bool) { return address(this).code.length > 400; }
function g() public view returns (uint) { return address(0).code.length; }
function h() public view returns (uint) { return address(1).code.length; }
}
// ====
// compileToEwasm: also
// ----
// constructor() ->
// gas irOptimized: 175145
// gas legacy: 241796
// gas legacyOptimized: 153411
// initCode() -> 0x20, 0
// f() -> true
// g() -> 0
// h() -> 0