You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
GDScript: Allow strict conversion when assigning typed variables
This commit is contained in:
@@ -743,12 +743,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
|
GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
|
||||||
|
|
||||||
if (src->get_type() != var_type) {
|
if (src->get_type() != var_type) {
|
||||||
|
if (Variant::can_convert_strict(src->get_type(), var_type)) {
|
||||||
|
Variant::CallError ce;
|
||||||
|
*dst = Variant::construct(var_type, const_cast<const Variant **>(&src), 1, ce);
|
||||||
|
} else {
|
||||||
err_text = "Trying to assign value of type '" + Variant::get_type_name(src->get_type()) +
|
err_text = "Trying to assign value of type '" + Variant::get_type_name(src->get_type()) +
|
||||||
"' to a variable of type '" + Variant::get_type_name(var_type) + "'.";
|
"' to a variable of type '" + Variant::get_type_name(var_type) + "'.";
|
||||||
OPCODE_BREAK;
|
OPCODE_BREAK;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
|
}
|
||||||
|
|
||||||
ip += 4;
|
ip += 4;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user