Warn if type(..).runtimeCode is used with assembly in the constructor.

This commit is contained in:
chriseth
2019-01-17 20:36:48 +01:00
parent 0bfdaa500a
commit 4669b06ab4
3 changed files with 87 additions and 1 deletions
@@ -0,0 +1,17 @@
contract Test {
function f() public pure returns (uint) {
return type(C).runtimeCode.length +
type(D).runtimeCode.length +
type(C).creationCode.length +
type(D).creationCode.length;
}
}
contract C {
constructor() public { assembly {} }
}
contract D is C {
constructor() public {}
}
// ----
// Warning: (77-96): The constructor of the contract (or its base) uses inline assembly. Because of that, it might be that the deployed bytecode is different from type(...).runtimeCode.
// Warning: (118-137): The constructor of the contract (or its base) uses inline assembly. Because of that, it might be that the deployed bytecode is different from type(...).runtimeCode.