GDScript: Forbid implicit type conversion

Since types are not present in release builds, this could cause issues
where a variable does not have the exact defined type.
This commit is contained in:
George Marques 2019-03-03 22:25:22 -03:00
parent a1e73dcc94
commit d0b08342b8
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
4 changed files with 16 additions and 110 deletions

View file

@ -55,7 +55,7 @@ struct GDScriptDataType {
StringName native_type;
Ref<Script> script_type;
bool is_type(const Variant &p_variant, bool p_allow_implicit_conversion = false) const {
bool is_type(const Variant &p_variant) const {
if (!has_type) return true; // Can't type check
switch (kind) {
@ -63,11 +63,7 @@ struct GDScriptDataType {
break;
case BUILTIN: {
Variant::Type var_type = p_variant.get_type();
bool valid = builtin_type == var_type;
if (!valid && p_allow_implicit_conversion) {
valid = Variant::can_convert_strict(var_type, builtin_type);
}
return valid;
return builtin_type == var_type;
} break;
case NATIVE: {
if (p_variant.get_type() == Variant::NIL) {