From d0b08342b8250aa76cdf934b97f2ab3ac114e259 Mon Sep 17 00:00:00 2001 From: George Marques Date: Sun, 3 Mar 2019 22:25:22 -0300 Subject: [PATCH] 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. --- modules/gdscript/gdscript_function.cpp | 11 +-- modules/gdscript/gdscript_function.h | 8 +- modules/gdscript/gdscript_parser.cpp | 105 +++---------------------- modules/gdscript/gdscript_parser.h | 2 +- 4 files changed, 16 insertions(+), 110 deletions(-) diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index cff9ba55b86..b2757f1b0b7 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -328,8 +328,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a continue; } - if (!argument_types[i].is_type(*p_args[i], true)) { - if (argument_types[i].is_type(Variant(), true)) { + if (!argument_types[i].is_type(*p_args[i])) { + if (argument_types[i].is_type(Variant())) { memnew_placement(&stack[i], Variant); continue; } else { @@ -339,12 +339,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a return Variant(); } } - if (argument_types[i].kind == GDScriptDataType::BUILTIN) { - Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err); - memnew_placement(&stack[i], Variant(arg)); - } else { - memnew_placement(&stack[i], Variant(*p_args[i])); - } + memnew_placement(&stack[i], Variant(*p_args[i])); } for (int i = p_argcount; i < _stack_size; i++) { memnew_placement(&stack[i], Variant); diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index cefc28d77f7..34fc51e92af 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -55,7 +55,7 @@ struct GDScriptDataType { StringName native_type; Ref