From 40c43da96f2e57a9e9c23d2dcab43bc700592d23 Mon Sep 17 00:00:00 2001 From: Thakee Nathees Date: Sun, 10 May 2020 10:35:29 +0530 Subject: [PATCH] set parser error when infer type is null (cherry picked from commit 687b1941b44f8ed560872cf2892bc66ea586db66) --- modules/gdscript/gdscript_parser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index ea4d4ca6fb2..5373974807f 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -7831,6 +7831,10 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) { _set_error("The assigned value doesn't have a set type; the variable type can't be inferred.", v.line); return; } + if (expr_type.kind == DataType::BUILTIN && expr_type.builtin_type == Variant::NIL) { + _set_error("The variable type cannot be inferred because its value is \"null\".", v.line); + return; + } v.data_type = expr_type; v.data_type.is_constant = false; } @@ -8212,6 +8216,10 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) { _set_error("The assigned value doesn't have a set type; the variable type can't be inferred.", lv->line); return; } + if (assign_type.kind == DataType::BUILTIN && assign_type.builtin_type == Variant::NIL) { + _set_error("The variable type cannot be inferred because its value is \"null\".", lv->line); + return; + } lv->datatype = assign_type; lv->datatype.is_constant = false; }