diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 08a5fa900..1dd6dcdd1 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -812,6 +812,12 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) define(_functionCall) << "gas()\n"; break; } + case FunctionType::Kind::Selfdestruct: + { + solAssert(arguments.size() == 1, ""); + define(_functionCall) << "selfdestruct(" << expressionAsType(*arguments.front(), *parameterTypes.front()) << ")\n"; + break; + } default: solUnimplemented("FunctionKind " + toString(static_cast(functionType->kind())) + " not yet implemented"); } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 69e645494..a0e59170b 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1238,11 +1238,13 @@ BOOST_AUTO_TEST_CASE(selfdestruct) } )"; u256 amount(130); - compileAndRun(sourceCode, amount); u160 address(23); - ABI_CHECK(callContractFunction("a(address)", address), bytes()); - BOOST_CHECK(!addressHasCode(m_contractAddress)); - BOOST_CHECK_EQUAL(balanceAt(address), amount); + ALSO_VIA_YUL( + compileAndRun(sourceCode, amount); + ABI_CHECK(callContractFunction("a(address)", address), bytes()); + BOOST_CHECK(!addressHasCode(m_contractAddress)); + BOOST_CHECK_EQUAL(balanceAt(address), amount); + ) } BOOST_AUTO_TEST_CASE(keccak256)