Переглянути джерело

GDScript: Fix `validate_call_arg()` for unresolved datatype

(cherry picked from commit 7da3110e6b7ad1a1b365eac75bcc71eeb0edd7f9)
Danil Alexeev 2 роки тому
батько
коміт
2054141848
1 змінених файлів з 5 додано та 3 видалено
  1. 5 3
      modules/gdscript/gdscript_analyzer.cpp

+ 5 - 3
modules/gdscript/gdscript_analyzer.cpp

@@ -4781,9 +4781,11 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
 		}
 		}
 		GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
 		GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
 
 
-		if ((arg_type.is_variant() || !arg_type.is_hard_type()) && !(par_type.is_hard_type() && par_type.is_variant())) {
-			// Argument can be anything, so this is unsafe.
-			mark_node_unsafe(p_call->arguments[i]);
+		if (arg_type.is_variant() || !arg_type.is_hard_type()) {
+			// Argument can be anything, so this is unsafe (unless the parameter is a hard variant).
+			if (!(par_type.is_hard_type() && par_type.is_variant())) {
+				mark_node_unsafe(p_call->arguments[i]);
+			}
 		} else if (par_type.is_hard_type() && !is_type_compatible(par_type, arg_type, true)) {
 		} else if (par_type.is_hard_type() && !is_type_compatible(par_type, arg_type, true)) {
 			// Supertypes are acceptable for dynamic compliance, but it's unsafe.
 			// Supertypes are acceptable for dynamic compliance, but it's unsafe.
 			mark_node_unsafe(p_call);
 			mark_node_unsafe(p_call);