diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:50:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 21:50:48 +0200 |
commit | 5046f666a1181675b39f156c38346525dc1c444e (patch) | |
tree | 442518e7def99a25559106f7bde5eb1f258c5f69 | |
parent | 963a27f8a2a2d05bd6ed9a3b3673702622179821 (diff) | |
parent | 687b1941b44f8ed560872cf2892bc66ea586db66 (diff) |
Merge pull request #38610 from ThakeeNathees/infer-type-null-error
set parser error when infer type is null
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 8cc6986f34..0c9ddb4fcf 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -8005,6 +8005,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; } @@ -8388,6 +8392,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; } |