mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support address().codehash
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f() public returns (bytes32) {
|
||||
// non-existent in tests
|
||||
return address(0).codehash;
|
||||
}
|
||||
function g() public returns (bytes32) {
|
||||
// precompile
|
||||
return address(0x1).codehash;
|
||||
}
|
||||
function h() public returns (bool) {
|
||||
return address(this).codehash != 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x0
|
||||
// g() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
|
||||
// h() -> true
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function f() public view returns (bytes32) {
|
||||
return address(this).codehash;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public view returns (bytes32) {
|
||||
return address(this).codehash;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: <constantinople
|
||||
// ----
|
||||
// TypeError 7598: (77-99): "codehash" is not supported by the VM version.
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() public view returns (bytes32) {
|
||||
return address(this).codehash;
|
||||
}
|
||||
function g() public view returns (bytes32) {
|
||||
return address(0).codehash;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
Reference in New Issue
Block a user