GDScript: Fix compiler generates incorrect bytecode for conversion return

This commit is contained in:
Danil Alexeev
2026-02-03 17:32:04 +03:00
parent 734f5473c1
commit d0eb19359e
14 changed files with 164 additions and 129 deletions
+3 -3
View File
@@ -2168,10 +2168,10 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
}
if (return_n->void_return) {
// Always return "null", even if the expression is a call to a void function.
gen->write_return(codegen.add_constant(Variant()));
// Always return `null`, even if the expression is a call to a `void` function.
gen->write_return(codegen.add_constant(Variant()), false);
} else {
gen->write_return(return_value);
gen->write_return(return_value, return_n->use_conversion);
}
if (return_value.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
codegen.generator->pop_temporary();