diff options
author | kobewi <kobewi4e@gmail.com> | 2021-10-03 20:55:54 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2021-10-03 21:16:54 +0200 |
commit | cb28469281e14cafc811fbd7b3633c1824e97463 (patch) | |
tree | b0d348fdcb4590474ea422ba1f9d56dd9a1606be | |
parent | 66ab3ce954a94fd43baed1dd74381dd32c893407 (diff) |
Allow void as return type for constructors
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index c35af9ca5b..fbba1c1069 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1035,7 +1035,10 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode * return_type.is_meta_type = false; p_function->set_datatype(return_type); if (p_function->return_type) { - push_error("Constructor cannot have an explicit return type.", p_function->return_type); + GDScriptParser::DataType declared_return = resolve_datatype(p_function->return_type); + if (declared_return.kind != GDScriptParser::DataType::BUILTIN || declared_return.builtin_type != Variant::NIL) { + push_error("Constructor cannot have an explicit return type.", p_function->return_type); + } } } else { GDScriptParser::DataType return_type = resolve_datatype(p_function->return_type); |