summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_compiler.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-31 15:55:35 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-31 15:55:35 +0100
commit6d9c9d30b9c50177a68695fba8a42998b2b49d4c (patch)
tree84dff620672748183dc72d831926e74c6ebeb81e /modules/gdscript/gdscript_compiler.cpp
parent361f3f1721205bf291d401a58e2226e083bb2bc4 (diff)
parenta47d4d57cac7077c9ad1c63f27ea095e6ce73561 (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.cpp7
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();
}