Prerequisites
It is possible to define a constant variable which stores a creation or runtime code of a contract.
Description
This behavior is correct, but the implementation does not verify that the variable stores a contract code in which the variable is being defined. It creates a circular dependencies. This results with no error during syntactic analysis, but results with an ICE during code geneneration stage.
Environment
- Compiler version: 0.8.31
- Compilation pipeline (legacy, IR, EOF): legacy, IR
- Target EVM version (as per compiler settings): default
- Framework/IDE (e.g. Foundry, Hardhat, Remix): all
- EVM execution environment / backend / blockchain client: ?
- Operating system: Tested on Macos but probably everywhere.
Steps to Reproduce
contract A {
bytes constant public code = type(A).creationCode;
}
Unhandled exception during test: /solidity/libsolidity/codegen/CompilerContext.cpp(255): Throw in function std::shared_ptr<evmasm::Assembly> solidity::frontend::CompilerContext::compiledContract(const ContractDefinition &) const
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Compiled contract not found.
[solidity::util::tag_comment*] = Compiled contract not found.