Merge pull request #8859 from ethereum/noRuntimeForImmutable

trigger error when runtimeCode is called on contracts with immutables
This commit is contained in:
chriseth
2020-05-07 16:08:27 +02:00
committed by GitHub
5 changed files with 47 additions and 4 deletions
@@ -0,0 +1,9 @@
contract A {
address public immutable user = address(0x0);
}
contract Test {
function test() public pure returns(bytes memory) {
return type(A).creationCode;
}
}
@@ -0,0 +1,11 @@
contract A {
address public immutable user = address(0x0);
}
contract Test {
function test() public pure returns(bytes memory) {
return type(A).runtimeCode;
}
}
// ----
// TypeError: (153-172): "runtimeCode" is not available for contracts containing immutable variables.
@@ -0,0 +1,13 @@
contract Base {
address public immutable user = address(0x0);
}
contract Derived is Base {}
contract Test {
function test() public pure returns(bytes memory) {
return type(Derived).runtimeCode;
}
}
// ----
// TypeError: (185-210): "runtimeCode" is not available for contracts containing immutable variables.