From 4b18c4e448c93fbb44c80b89e744cfacea8d8bc4 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 29 May 2018 23:16:56 -0300 Subject: Add typed instructions to GDScript - Typed assignment (built-in, native, and script). - Cast (built-in conversion; native and script checks). - Check type of functions arguments on call. - Check type of members on set. --- modules/gdscript/gdscript.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/gdscript/gdscript.cpp') diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index ae8dcfc370..a8916c2a2e 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -941,8 +941,12 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) { if (err.error == Variant::CallError::CALL_OK) { return true; //function exists, call was successful } - } else + } else { + if (!E->get().data_type.is_type(p_value)) { + return false; // Type mismatch + } members[E->get().index] = p_value; + } return true; } } -- cgit v1.2.3