From 762bb5843b72d5921a02484bdb850c28fe6e48a9 Mon Sep 17 00:00:00 2001 From: David Sichma Date: Fri, 12 Mar 2021 15:04:45 +0100 Subject: Fixed match test expression for temporaries Fixed that a potentially popped temporary was used for the value in match statements. --- modules/gdscript/gdscript_compiler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/gdscript/gdscript_compiler.cpp') diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 06d628d23f..765b9058f1 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -1511,17 +1511,17 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui codegen.start_block(); // Evaluate the match expression. - GDScriptCodeGenerator::Address value_local = codegen.add_local("@match_value", _gdtype_from_datatype(match->test->get_datatype())); - GDScriptCodeGenerator::Address value = _parse_expression(codegen, error, match->test); + GDScriptCodeGenerator::Address value = codegen.add_local("@match_value", _gdtype_from_datatype(match->test->get_datatype())); + GDScriptCodeGenerator::Address value_expr = _parse_expression(codegen, error, match->test); if (error) { return error; } // Assign to local. // TODO: This can be improved by passing the target to parse_expression(). - gen->write_assign(value_local, value); + gen->write_assign(value, value_expr); - if (value.mode == GDScriptCodeGenerator::Address::TEMPORARY) { + if (value_expr.mode == GDScriptCodeGenerator::Address::TEMPORARY) { codegen.generator->pop_temporary(); } -- cgit v1.2.3