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

Fixed crash for lambda bind attempt outside method instance

This commit is contained in:
Brian Fiete 2022-01-07 08:03:33 -05:00
parent 36311cab2d
commit 24c91d373c

View file

@ -13427,7 +13427,11 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
BfTokenNode* newToken = NULL;
BfAllocTarget allocTarget = ResolveAllocTarget(lambdaBindExpr->mNewToken, newToken);
if ((mModule->mCurMethodState != NULL) && (mModule->mCurMethodState->mClosureState != NULL) && (mModule->mCurMethodState->mClosureState->mBlindCapturing))
if (mModule->mCurMethodInstance == NULL)
mModule->Fail("Invalid use of lambda bind expression", lambdaBindExpr);
if (((mModule->mCurMethodState != NULL) && (mModule->mCurMethodState->mClosureState != NULL) && (mModule->mCurMethodState->mClosureState->mBlindCapturing)) ||
(mModule->mCurMethodInstance == NULL))
{
// We're just capturing. We just need to visit the bodies here. This helps infinite recursion with local methods containing lambdas calling each other
if (lambdaBindExpr->mBody != NULL)