mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Revert "Forbid implicit type conversion in GDScript"
This commit is contained in:
parent
49d82f245b
commit
425ec6914c
4 changed files with 110 additions and 16 deletions
|
@ -55,7 +55,7 @@ struct GDScriptDataType {
|
|||
StringName native_type;
|
||||
Ref<Script> script_type;
|
||||
|
||||
bool is_type(const Variant &p_variant) const {
|
||||
bool is_type(const Variant &p_variant, bool p_allow_implicit_conversion = false) const {
|
||||
if (!has_type) return true; // Can't type check
|
||||
|
||||
switch (kind) {
|
||||
|
@ -63,7 +63,11 @@ struct GDScriptDataType {
|
|||
break;
|
||||
case BUILTIN: {
|
||||
Variant::Type var_type = p_variant.get_type();
|
||||
return builtin_type == var_type;
|
||||
bool valid = builtin_type == var_type;
|
||||
if (!valid && p_allow_implicit_conversion) {
|
||||
valid = Variant::can_convert_strict(var_type, builtin_type);
|
||||
}
|
||||
return valid;
|
||||
} break;
|
||||
case NATIVE: {
|
||||
if (p_variant.get_type() == Variant::NIL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue