diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 35303fe9ac47..9d317a1b6613 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -1278,7 +1278,7 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression: bool valid = true; Variant::evaluate(op->op, a, b, r_ret, valid); if (!valid) { - r_error_str = vformat(RTR("Invalid operands to operator %s, %s and %s."), Variant::get_operator_name(op->op), Variant::get_type_name(a.get_type()), Variant::get_type_name(b.get_type())); + r_error_str = vformat(RTR("Invalid operands to operator %s, %s and %s."), Variant::get_operator_name(op->op), a.get_full_type_name(), b.get_full_type_name()); return true; } @@ -1302,7 +1302,7 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression: bool valid; r_ret = base.get(idx, &valid); if (!valid) { - r_error_str = vformat(RTR("Invalid index of type %s for base type %s"), Variant::get_type_name(idx.get_type()), Variant::get_type_name(base.get_type())); + r_error_str = vformat(RTR("Invalid index of type %s for base type %s"), idx.get_full_type_name(), base.get_full_type_name()); return true; } @@ -1319,7 +1319,7 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression: bool valid; r_ret = base.get_named(index->name, valid); if (!valid) { - r_error_str = vformat(RTR("Invalid named index '%s' for base type %s"), String(index->name), Variant::get_type_name(base.get_type())); + r_error_str = vformat(RTR("Invalid named index '%s' for base type %s"), String(index->name), base.get_full_type_name()); return true; } diff --git a/core/variant/array.cpp b/core/variant/array.cpp index f7a86b8fa386..115147592710 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -235,14 +235,14 @@ void Array::assign(const Array &p_array) { for (int i = 0; i < size; i++) { const Variant &element = source[i]; if (element.get_type() != Variant::NIL && (element.get_type() != Variant::OBJECT || !typed.validate_object(element, "assign"))) { - ERR_FAIL_MSG(vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, Variant::get_type_name(element.get_type()), Variant::get_type_name(typed.type))); + ERR_FAIL_MSG(vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, element.get_full_type_name(), typed.get_contained_type_name())); } } _p->array = p_array._p->array; return; } if (typed.type == Variant::OBJECT || source_typed.type == Variant::OBJECT) { - ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", Variant::get_type_name(source_typed.type), Variant::get_type_name(typed.type))); + ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", source_typed.get_contained_type_name(), typed.get_contained_type_name())); } Vector array; @@ -258,11 +258,11 @@ void Array::assign(const Array &p_array) { continue; } if (!Variant::can_convert_strict(value->get_type(), typed.type)) { - ERR_FAIL_MSG(vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, Variant::get_type_name(value->get_type()), Variant::get_type_name(typed.type))); + ERR_FAIL_MSG(vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, value->get_full_type_name(), typed.get_contained_type_name())); } Callable::CallError ce; Variant::construct(typed.type, data[i], &value, 1, ce); - ERR_FAIL_COND_MSG(ce.error, vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, Variant::get_type_name(value->get_type()), Variant::get_type_name(typed.type))); + ERR_FAIL_COND_MSG(ce.error, vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, value->get_full_type_name(), typed.get_contained_type_name())); } } else if (Variant::can_convert_strict(source_typed.type, typed.type)) { // from primitives to different convertible primitives @@ -270,10 +270,10 @@ void Array::assign(const Array &p_array) { const Variant *value = source + i; Callable::CallError ce; Variant::construct(typed.type, data[i], &value, 1, ce); - ERR_FAIL_COND_MSG(ce.error, vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, Variant::get_type_name(value->get_type()), Variant::get_type_name(typed.type))); + ERR_FAIL_COND_MSG(ce.error, vformat(R"(Unable to convert array index %d from "%s" to "%s".)", i, value->get_full_type_name(), typed.get_contained_type_name())); } } else { - ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", Variant::get_type_name(source_typed.type), Variant::get_type_name(typed.type))); + ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", source_typed.get_contained_type_name(), typed.get_contained_type_name())); } _p->array = array; diff --git a/core/variant/container_type_validate.h b/core/variant/container_type_validate.h index 8971fadf7320..25fcc02cab87 100644 --- a/core/variant/container_type_validate.h +++ b/core/variant/container_type_validate.h @@ -34,12 +34,53 @@ #include "core/object/script_language.h" #include "core/variant/variant.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_GDSCRIPT_ENABLED +#include "modules/gdscript/gdscript.h" +#endif // MODULE_GDSCRIPT_ENABLED + struct ContainerTypeValidate { Variant::Type type = Variant::NIL; StringName class_name; Ref