GDScript: Allow void functions to return calls to other void functions

This commit is contained in:
George Marques 2023-01-27 17:54:07 -03:00
parent e1648b3327
commit a47d4d57ca
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
8 changed files with 78 additions and 10 deletions

View file

@ -1859,7 +1859,12 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
}
}
gen->write_return(return_value);
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()));
} else {
gen->write_return(return_value);
}
if (return_value.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
codegen.generator->pop_temporary();
}