From e420f5f910443d4b64c2f4856d29ec47d3aa85b7 Mon Sep 17 00:00:00 2001 From: Mivort Date: Tue, 30 Sep 2025 01:23:22 +0100 Subject: [PATCH] Provide error context for typed array clone check This patch adds output of `ConvertError`'s `Display` to debug-only check's panic message which provides additional context when type mismatch happens. Panic message would include the intended type name and what was given instead of it. The output would look roughly like this: ``` copied array should have same type as original array: expected array of type Builtin(DICTIONARY), got Untyped: [] ``` --- godot-core/src/builtin/collections/array.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/godot-core/src/builtin/collections/array.rs b/godot-core/src/builtin/collections/array.rs index cdbd5ba5d..111feda91 100644 --- a/godot-core/src/builtin/collections/array.rs +++ b/godot-core/src/builtin/collections/array.rs @@ -1245,8 +1245,9 @@ impl Clone for Array { // Double-check copy's runtime type in Debug mode. if cfg!(debug_assertions) { - copy.with_checked_type() - .expect("copied array should have same type as original array") + copy.with_checked_type().unwrap_or_else(|e| { + panic!("copied array should have same type as original array: {e}") + }) } else { copy }