1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 20:12:21 +02:00

Fix for early unconditional return in dtor

This commit is contained in:
Brian Fiete 2021-08-30 09:37:19 -07:00
parent 6df69a7d95
commit ac8d5cf014

View file

@ -15049,13 +15049,9 @@ void BfModule::EmitReturn(const BfTypedValue& val)
else else
{ {
EmitDeferredScopeCalls(false, NULL); EmitDeferredScopeCalls(false, NULL);
if (val) if (val)
{ {
if (mCurMethodInstance->mReturnType->IsValuelessType()) BF_ASSERT(mBfIRBuilder->mIgnoreWrites);
mBfIRBuilder->CreateRetVoid();
else
mBfIRBuilder->CreateRet(val.mValue);
} }
} }
@ -15803,6 +15799,10 @@ void BfModule::EmitDtorBody()
if (auto bodyBlock = BfNodeDynCast<BfBlock>(methodDef->mBody)) if (auto bodyBlock = BfNodeDynCast<BfBlock>(methodDef->mBody))
{ {
VisitEmbeddedStatement(bodyBlock); VisitEmbeddedStatement(bodyBlock);
// We don't have an exit block and no return was actually emitted, so we set this to false to ensure a proper ret emission later
mCurMethodState->mHadReturn = false;
if (bodyBlock->mCloseBrace != NULL) if (bodyBlock->mCloseBrace != NULL)
{ {
UpdateSrcPos(bodyBlock->mCloseBrace); UpdateSrcPos(bodyBlock->mCloseBrace);