mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-19 00:20:25 +02:00
Fixed issue with return from unscoped block in string interpolation
This commit is contained in:
parent
8cccec20fa
commit
c2a2cf221a
2 changed files with 11 additions and 4 deletions
|
@ -1034,6 +1034,7 @@ public:
|
|||
bool mNoBind;
|
||||
bool mInConditionalBlock; // IE: RHS of ((A) && (B)), indicates an allocation in 'B' won't be dominated by a dtor, for example
|
||||
bool mAllowUinitReads;
|
||||
bool mDisableReturns;
|
||||
bool mCancelledDeferredCall;
|
||||
bool mNoObjectAccessChecks;
|
||||
bool mHadIgnoredError;
|
||||
|
@ -1073,6 +1074,7 @@ public:
|
|||
mDisableChecks = false;
|
||||
mInConditionalBlock = false;
|
||||
mAllowUinitReads = false;
|
||||
mDisableReturns = false;
|
||||
mCancelledDeferredCall = false;
|
||||
mNoObjectAccessChecks = false;
|
||||
mInDeferredBlock = false;
|
||||
|
|
|
@ -3143,7 +3143,7 @@ void BfModule::VisitEmbeddedStatement(BfAstNode* stmt, BfExprEvaluator* exprEval
|
|||
if ((flags & BfEmbeddedStatementFlags_Unscoped) != 0)
|
||||
{
|
||||
SetAndRestoreValue<BfExprEvaluator*> prevExprEvaluator(mCurMethodState->mCurScope->mExprEvaluator, exprEvaluator);
|
||||
|
||||
SetAndRestoreValue<bool> prevAllowReturn(mCurMethodState->mDisableReturns, true);
|
||||
VisitCodeBlock(block);
|
||||
}
|
||||
else if (mCurMethodState != NULL)
|
||||
|
@ -4983,9 +4983,14 @@ static int gRetIdx = 0;
|
|||
|
||||
void BfModule::Visit(BfReturnStatement* returnStmt)
|
||||
{
|
||||
if (mCurMethodInstance == NULL)
|
||||
if ((mCurMethodInstance == NULL) || (mCurMethodState->mDisableReturns))
|
||||
{
|
||||
Fail("Unexpected return", returnStmt);
|
||||
if (returnStmt->mExpression != NULL)
|
||||
{
|
||||
BfExprEvaluator exprEvaluator(this);
|
||||
CreateValueFromExpression(exprEvaluator, returnStmt->mExpression);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue