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

Scope fix

This commit is contained in:
Brian Fiete 2021-09-12 18:22:52 -07:00
parent 484a0bf375
commit f9bb9e84e7

View file

@ -3409,9 +3409,13 @@ void BfModule::VisitCodeBlock(BfBlock* block)
if ((exprEvaluator->mResult) && (!exprEvaluator->mResult.mType->IsValuelessType()) && (!exprEvaluator->mResult.IsAddr()))
{
auto useScope = mCurMethodState->mCurScope;
if ((useScope != NULL) && (useScope->mPrevScope != NULL))
useScope = useScope->mPrevScope;
FixIntUnknown(exprEvaluator->mResult, exprEvaluator->mExpectingType);
// We need to make sure we don't retain any values through the scope's ValueScopeHardEnd - and extend alloca through previous scope
SetAndRestoreValue<BfScopeData*> prevScope(mCurMethodState->mCurScope, mCurMethodState->mCurScope->mPrevScope);
SetAndRestoreValue<BfScopeData*> prevScope(mCurMethodState->mCurScope, useScope);
exprEvaluator->mResult = MakeAddressable(exprEvaluator->mResult);
}
}