From 30d4d3fa5ec241dd24b25910621bace9427202d0 Mon Sep 17 00:00:00 2001 From: mashumafi Date: Sun, 19 Feb 2023 21:24:39 -0500 Subject: Fix: Func with typed args error when arg is null --- modules/gdscript/gdscript_function.h | 10 ++++---- .../runtime/features/typed_argument_is_null.gd | 27 ++++++++++++++++++++++ .../runtime/features/typed_argument_is_null.out | 3 +++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 modules/gdscript/tests/scripts/runtime/features/typed_argument_is_null.gd create mode 100644 modules/gdscript/tests/scripts/runtime/features/typed_argument_is_null.out (limited to 'modules/gdscript') diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 2624fb8dd9..9f33497eb3 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -105,9 +105,10 @@ public: return false; } - Object *obj = p_variant.get_validated_object(); + bool was_freed = false; + Object *obj = p_variant.get_validated_object_with_check(was_freed); if (!obj) { - return false; + return !was_freed; } if (!ClassDB::is_parent_class(obj->get_class_name(), native_type)) { @@ -124,9 +125,10 @@ public: return false; } - Object *obj = p_variant.get_validated_object(); + bool was_freed = false; + Object *obj = p_variant.get_validated_object_with_check(was_freed); if (!obj) { - return false; + return !was_freed; } Ref