summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_parser.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-01-16 11:03:16 +0100
committerGitHub <noreply@github.com>2019-01-16 11:03:16 +0100
commitb4ec37af2cc4a626aa46b9af341e6d5b9e0676ce (patch)
tree192d9c4855d644934e057894bfdda162c65d4b4a /modules/gdscript/gdscript_parser.cpp
parente7844505b18fecebad1ce84ddc20fe510c469028 (diff)
parent31433ae8e4159d01ed57c334c72eb8593185b145 (diff)
Merge pull request #25014 from vnen/gdscript-fixes
Fix some GDScript issues
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r--modules/gdscript/gdscript_parser.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index b0743af1b4..160fc48f92 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -6224,7 +6224,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
if (check_types && index_type.has_type) {
if (base_type.kind == DataType::BUILTIN) {
// Check if indexing is valid
- bool error = index_type.kind != DataType::BUILTIN;
+ bool error = index_type.kind != DataType::BUILTIN && base_type.builtin_type != Variant::DICTIONARY;
if (!error) {
switch (base_type.builtin_type) {
// Expect int or real as index
@@ -6767,10 +6767,10 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
valid = _get_function_signature(base_type, callee_name, return_type, arg_types,
default_args_count, is_static, is_vararg);
- if (valid) {
- return_type = original_type;
- return_type.is_meta_type = false;
- }
+ return_type = original_type;
+ return_type.is_meta_type = false;
+
+ valid = true; // There's always an initializer, we can asume this is true
}
if (!valid) {
@@ -6829,6 +6829,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
} break;
}
+#ifdef DEBUG_ENABLED
if (!check_types) {
return return_type;
}
@@ -6854,11 +6855,9 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
if (!par_type.has_type) {
_mark_line_as_unsafe(p_call->line);
-#ifdef DEBUG_ENABLED
if (par_type.may_yield && p_call->arguments[i]->type == Node::TYPE_OPERATOR) {
_add_warning(GDScriptWarning::FUNCTION_MAY_YIELD, p_call->line, _find_function_name(static_cast<OperatorNode *>(p_call->arguments[i])));
}
-#endif // DEBUG_ENABLED
} else if (!_is_type_compatible(arg_types[i - arg_diff], par_type, true)) {
// Supertypes are acceptable for dynamic compliance
if (!_is_type_compatible(par_type, arg_types[i - arg_diff])) {
@@ -6871,14 +6870,14 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
_mark_line_as_unsafe(p_call->line);
}
} else {
-#ifdef DEBUG_ENABLED
if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_type.kind == DataType::BUILTIN && par_type.builtin_type == Variant::REAL) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, p_call->line, callee_name);
}
-#endif // DEBUG_ENABLED
}
}
+#endif // DEBUG_ENABLED
+
return return_type;
}
@@ -8110,6 +8109,7 @@ Error GDScriptParser::_parse(const String &p_base_path) {
check_types = false;
#endif
+#ifdef DEBUG_ENABLED
// Resolve all class-level stuff before getting into function blocks
_check_class_level_types(main_class);
@@ -8124,7 +8124,6 @@ Error GDScriptParser::_parse(const String &p_base_path) {
return ERR_PARSE_ERROR;
}
-#ifdef DEBUG_ENABLED
// Resolve warning ignores
Vector<Pair<int, String> > warning_skips = tokenizer->get_warning_skips();
bool warning_is_error = GLOBAL_GET("debug/gdscript/warnings/treat_warnings_as_errors").booleanize();