From 24c91d373c1ddbd668a909e0827c1e9616fc972f Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 7 Jan 2022 08:03:33 -0500 Subject: [PATCH] Fixed crash for lambda bind attempt outside method instance --- IDEHelper/Compiler/BfExprEvaluator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 7462d4ba..03abd3f6 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -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)