mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce address(...).code
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: false
|
||||
// ----
|
||||
// constructor() ->
|
||||
// initCode() -> 0x20, 0
|
||||
// f() -> true
|
||||
// g() -> 0
|
||||
// h() -> 0
|
||||
Reference in New Issue
Block a user