From b9219bedf73ad933a5b93de5c09d86ed58977c18 Mon Sep 17 00:00:00 2001 From: jmb462 Date: Sat, 11 Sep 2021 21:05:44 +0200 Subject: Prevent non explicit inferring parameter from null --- modules/gdscript/gdscript_analyzer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/gdscript') diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index fc0bef3ba2..8175738c0e 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1478,6 +1478,10 @@ void GDScriptAnalyzer::resolve_parameter(GDScriptParser::ParameterNode *p_parame } } + if (result.builtin_type == Variant::Type::NIL && result.type_source == GDScriptParser::DataType::ANNOTATED_INFERRED && p_parameter->datatype_specifier == nullptr) { + push_error(vformat(R"(Could not infer the type of the variable "%s" because the initial value is "null".)", p_parameter->identifier->name), p_parameter->default_value); + } + p_parameter->set_datatype(result); } -- cgit v1.2.3