mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
GDScript: Fix type conversion in assignment with operation
This commit is contained in:
parent
f065b34e96
commit
475d7f0e52
3 changed files with 25 additions and 18 deletions
|
@ -764,15 +764,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
GET_VARIANT_PTR(dst, 2);
|
||||
GET_VARIANT_PTR(src, 3);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
Variant::Type var_type = (Variant::Type)_code_ptr[ip + 1];
|
||||
GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
|
||||
|
||||
if (src->get_type() != var_type) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (Variant::can_convert_strict(src->get_type(), var_type)) {
|
||||
#endif // DEBUG_ENABLED
|
||||
Variant::CallError ce;
|
||||
*dst = Variant::construct(var_type, const_cast<const Variant **>(&src), 1, ce);
|
||||
} else {
|
||||
#ifdef DEBUG_ENABLED
|
||||
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) + "'.";
|
||||
OPCODE_BREAK;
|
||||
|
@ -780,9 +782,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
} else {
|
||||
#endif // DEBUG_ENABLED
|
||||
*dst = *src;
|
||||
#ifdef DEBUG_ENABLED
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
ip += 4;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue