-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Closed
Copy link
Labels
bug 🐛should report better errorError is just badly reported. Should be a proper type error - source is not fine.Error is just badly reported. Should be a proper type error - source is not fine.
Description
Description
function f() { new D(); }
contract D {
receive() external payable { f; }
}
generates the following invalid Yul code (solc --ir test.sol
)
Internal compiler error during compilation:
/solidity/libsolidity/codegen/ir/IRGenerator.cpp(107): Throw in function pair<std::string, std::string> solidity::frontend::IRGenerator::run(const solidity::frontend::ContractDefinition &, const map<const solidity::frontend::ContractDefinition *, const std::string_view> &)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what:
object "D_16" {
code {
mstore(64, 128)
if callvalue() { revert(0, 0) }
constructor_D_16()
codecopy(0, dataoffset("D_16_deployed"), datasize("D_16_deployed"))
return(0, datasize("D_16_deployed"))
function constructor_D_16() {
}
}
object "D_16_deployed" {
code {
mstore(64, 128)
if iszero(lt(calldatasize(), 4))
{
let selector := shift_right_224_unsigned(calldataload(0))
switch selector
default {}
}
if iszero(calldatasize()) { fun__15() stop() }
revert(0, 0)
function abi_encode_tuple__to__fromStack(headStart ) -> tail {
tail := add(headStart, 0)
}
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function dispatch_internal_in_0_out_0(fun) {
switch fun
case 9
{
fun_f_9()
}
default { panic_error_0x51() }
}
function fun__15() {
let expr_12_functionIdentifier := 9
}
function fun_f_9() {
let _1 := allocate_unbounded()
let _2 := add(_1, datasize("D_16"))
if or(gt(_2, 0xffffffffffffffff), lt(_2, _1)) { panic_error_0x41() }
datacopy(_1, dataoffset("D_16"), datasize("D_16"))
_2 := abi_encode_tuple__to__fromStack(_2)
let expr_6_address := create(0, _1, sub(_2, _1))
if iszero(expr_6_address) { revert_forward_1() }
}
function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x41)
revert(0, 0x24)
}
function panic_error_0x51() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x51)
revert(0, 0x24)
}
function revert_forward_1() {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
function shift_right_224_unsigned(value) -> newValue {
newValue :=
shr(224, value)
}
}
}
}
Invalid IR generated:
Warning: "switch" statement with only a default case.
Error: Unknown data object "D_16".
Error: Unknown data object "D_16".
Error: Unknown data object "D_16".
Environment
- Compiler version: 6e1d61a
Steps to Reproduce
$ solc --ir test.sol
Metadata
Metadata
Assignees
Labels
bug 🐛should report better errorError is just badly reported. Should be a proper type error - source is not fine.Error is just badly reported. Should be a proper type error - source is not fine.