GDScript: Prevent function states from leaking into typed temporaries, when overwriting with coroutines

This commit is contained in:
HolonProduction
2026-01-27 16:47:14 +01:00
parent 780b6891e6
commit 7c6a17647f
3 changed files with 33 additions and 2 deletions
+5 -2
View File
@@ -603,12 +603,15 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
case GDScriptParser::Node::CALL: {
const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_expression);
bool is_awaited = p_expression == awaited_node;
GDScriptDataType type = _gdtype_from_datatype(call->get_datatype(), codegen.script);
GDScriptCodeGenerator::Address result;
if (p_root) {
result = GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::NIL);
} else if (is_awaited) {
// When called with await, we need to use an untyped temporary regardless of whether the base
// class function is a coroutine, because an inherited class could return a function state object.
result = codegen.add_temporary();
} else {
result = codegen.add_temporary(type);
result = codegen.add_temporary(_gdtype_from_datatype(call->get_datatype(), codegen.script));
}
Vector<GDScriptCodeGenerator::Address> arguments;