1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-15 14:54:09 +02:00

Fixed dyn scope detection in null conditional

This commit is contained in:
Brian Fiete 2021-10-28 10:48:05 -07:00
parent e018c08134
commit b10edc6f0a

View file

@ -3021,14 +3021,22 @@ void BfExprEvaluator::Evaluate(BfAstNode* astNode, bool propogateNullConditional
if (astNode->IsExact<BfParenthesizedExpression>()) if (astNode->IsExact<BfParenthesizedExpression>())
propogateNullConditional = false; propogateNullConditional = false;
bool scopeWasConditional = false;
BfPendingNullConditional* pendingNullCond = NULL; BfPendingNullConditional* pendingNullCond = NULL;
mInsidePendingNullable = false;
if (mModule->mCurMethodState != NULL) if (mModule->mCurMethodState != NULL)
{ {
scopeWasConditional = mModule->mCurMethodState->mCurScope->mIsConditional;
pendingNullCond = mModule->mCurMethodState->mPendingNullConditional; pendingNullCond = mModule->mCurMethodState->mPendingNullConditional;
if (!propogateNullConditional) if (!propogateNullConditional)
mModule->mCurMethodState->mPendingNullConditional = NULL; mModule->mCurMethodState->mPendingNullConditional = NULL;
if (pendingNullCond != NULL)
{
mInsidePendingNullable = true;
mModule->mCurMethodState->mCurScope->mIsConditional = true;
}
} }
mInsidePendingNullable = pendingNullCond != NULL;
astNode->Accept(this); astNode->Accept(this);
GetResult(); GetResult();
@ -3042,13 +3050,19 @@ void BfExprEvaluator::Evaluate(BfAstNode* astNode, bool propogateNullConditional
if ((mBfEvalExprFlags & BfEvalExprFlags_AllowIntUnknown) == 0) if ((mBfEvalExprFlags & BfEvalExprFlags_AllowIntUnknown) == 0)
mModule->FixIntUnknown(mResult); mModule->FixIntUnknown(mResult);
if ((!propogateNullConditional) && (mModule->mCurMethodState != NULL)) if (mModule->mCurMethodState != NULL)
{
if (mInsidePendingNullable)
mModule->mCurMethodState->mCurScope->mIsConditional = scopeWasConditional;
if (!propogateNullConditional)
{ {
if (mModule->mCurMethodState->mPendingNullConditional != NULL) if (mModule->mCurMethodState->mPendingNullConditional != NULL)
mResult = mModule->FlushNullConditional(mResult, ignoreNullConditional); mResult = mModule->FlushNullConditional(mResult, ignoreNullConditional);
mModule->mCurMethodState->mPendingNullConditional = pendingNullCond; mModule->mCurMethodState->mPendingNullConditional = pendingNullCond;
} }
} }
}
void BfExprEvaluator::Visit(BfErrorNode* errorNode) void BfExprEvaluator::Visit(BfErrorNode* errorNode)
{ {