diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-31 15:55:35 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-31 15:55:35 +0100 |
commit | 6d9c9d30b9c50177a68695fba8a42998b2b49d4c (patch) | |
tree | 84dff620672748183dc72d831926e74c6ebeb81e /modules/gdscript/gdscript_compiler.cpp | |
parent | 361f3f1721205bf291d401a58e2226e083bb2bc4 (diff) | |
parent | a47d4d57cac7077c9ad1c63f27ea095e6ce73561 (diff) |
Merge pull request #72206 from vnen/gdscript-allow-void-return-shorthand
GDScript: Allow void functions to return calls to other void functions
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 373d8a3efd..46cd4b0d55 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -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(); } |