GDScript: Fix lambda resolution with cyclic references

This commit is contained in:
Danil Alexeev 2023-08-23 12:37:18 +03:00
parent 6758a7f8c0
commit 89429b0273
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
10 changed files with 127 additions and 31 deletions

View file

@ -3151,6 +3151,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_preload(ExpressionNode *p_
GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_previous_operand, bool p_can_assign) {
LambdaNode *lambda = alloc_node<LambdaNode>();
lambda->parent_function = current_function;
lambda->parent_lambda = current_lambda;
FunctionNode *function = alloc_node<FunctionNode>();
function->source_lambda = lambda;
@ -3178,6 +3180,9 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_p
FunctionNode *previous_function = current_function;
current_function = function;
LambdaNode *previous_lambda = current_lambda;
current_lambda = lambda;
SuiteNode *body = alloc_node<SuiteNode>();
body->parent_function = current_function;
body->parent_block = current_suite;
@ -3215,6 +3220,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_p
}
current_function = previous_function;
current_lambda = previous_lambda;
in_lambda = previous_in_lambda;
lambda->function = function;