1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Made paths with NoReturn calls mark variables as assigned

This commit is contained in:
Brian Fiete 2022-02-14 07:25:20 -05:00
parent 502c46dc2f
commit 8d0a415eb7
3 changed files with 7 additions and 5 deletions

View file

@ -5605,6 +5605,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
{
mModule->mCurMethodState->SetHadReturn(true);
mModule->mCurMethodState->mLeftBlockUncond = true;
mModule->MarkScopeLeft(&mModule->mCurMethodState->mHeadScope, true);
}
if (mModule->mCurTypeInstance != NULL)

View file

@ -15519,9 +15519,9 @@ void BfModule::EmitDeferredScopeCalls(bool useSrcPositions, BfScopeData* scopeDa
}*/
}
void BfModule::MarkScopeLeft(BfScopeData* scopeData)
{
if (mCurMethodState->mDeferredLocalAssignData != NULL)
void BfModule::MarkScopeLeft(BfScopeData* scopeData, bool isNoReturn)
{
if ((mCurMethodState->mDeferredLocalAssignData != NULL) && (!isNoReturn))
{
auto deferredLocalAssignData = mCurMethodState->mDeferredLocalAssignData;
@ -15550,7 +15550,8 @@ void BfModule::MarkScopeLeft(BfScopeData* scopeData)
}
if (!hadAssignment)
{
localDef->mHadExitBeforeAssign = true;
if (!isNoReturn)
localDef->mHadExitBeforeAssign = true;
mCurMethodState->LocalDefined(localDef);
}
}

View file

@ -1845,7 +1845,7 @@ public:
void ClearLifetimeEnds();
bool HasDeferredScopeCalls(BfScopeData* scope);
void EmitDeferredScopeCalls(bool useSrcPositions, BfScopeData* scope, BfIRBlock doneBlock = BfIRBlock());
void MarkScopeLeft(BfScopeData* scopeData);
void MarkScopeLeft(BfScopeData* scopeData, bool isNoReturn = false);
BfGenericParamType* GetGenericParamType(BfGenericParamKind paramKind, int paramIdx);
BfType* ResolveGenericType(BfType* unspecializedType, BfTypeVector* typeGenericArguments, BfTypeVector* methodGenericArguments, bool allowFail = false);
BfType* ResolveSelfType(BfType* type, BfTypeInstance* selfType);