Core: Fix implicit conversions in ContainerTypeValidate
This commit is contained in:
@@ -46,7 +46,6 @@ struct ContainerTypeValidate {
|
|||||||
const char *where = "container";
|
const char *where = "container";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Coerces String and StringName into each other and int into float when needed.
|
|
||||||
_FORCE_INLINE_ bool _internal_validate(Variant &inout_variant, const char *p_operation, bool p_output_errors) const {
|
_FORCE_INLINE_ bool _internal_validate(Variant &inout_variant, const char *p_operation, bool p_output_errors) const {
|
||||||
if (type == Variant::NIL) {
|
if (type == Variant::NIL) {
|
||||||
return true;
|
return true;
|
||||||
@@ -56,15 +55,17 @@ private:
|
|||||||
if (inout_variant.get_type() == Variant::NIL && type == Variant::OBJECT) {
|
if (inout_variant.get_type() == Variant::NIL && type == Variant::OBJECT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (type == Variant::STRING && inout_variant.get_type() == Variant::STRING_NAME) {
|
|
||||||
inout_variant = String(inout_variant);
|
if (Variant::can_convert_strict(inout_variant.get_type(), type)) {
|
||||||
return true;
|
Variant converted_to;
|
||||||
} else if (type == Variant::STRING_NAME && inout_variant.get_type() == Variant::STRING) {
|
const Variant *converted_from = &inout_variant;
|
||||||
inout_variant = StringName(inout_variant);
|
Callable::CallError call_error;
|
||||||
return true;
|
Variant::construct(type, converted_to, &converted_from, 1, call_error);
|
||||||
} else if (type == Variant::FLOAT && inout_variant.get_type() == Variant::INT) {
|
|
||||||
inout_variant = (float)inout_variant;
|
if (call_error.error == Callable::CallError::CALL_OK) {
|
||||||
return true;
|
inout_variant = converted_to;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_output_errors) {
|
if (p_output_errors) {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
func test():
|
||||||
|
# GH-114299
|
||||||
|
var a1: Array[PackedInt32Array] = [[1]]
|
||||||
|
var a2 = [[2]] as Array[PackedInt32Array]
|
||||||
|
print(var_to_str(a1))
|
||||||
|
print(var_to_str(a2))
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
GDTEST_OK
|
||||||
|
Array[PackedInt32Array]([PackedInt32Array(1)])
|
||||||
|
Array[PackedInt32Array]([PackedInt32Array(2)])
|
||||||
Reference in New Issue
Block a user