Skip to content

Commit e420f5f

Browse files
committed
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: [] ```
1 parent c3f705b commit e420f5f

File tree

1 file changed

+3
-2
lines changed
  • godot-core/src/builtin/collections

1 file changed

+3
-2
lines changed

godot-core/src/builtin/collections/array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,9 @@ impl<T: ArrayElement> Clone for Array<T> {
12451245

12461246
// Double-check copy's runtime type in Debug mode.
12471247
if cfg!(debug_assertions) {
1248-
copy.with_checked_type()
1249-
.expect("copied array should have same type as original array")
1248+
copy.with_checked_type().unwrap_or_else(|e| {
1249+
panic!("copied array should have same type as original array: {e}")
1250+
})
12501251
} else {
12511252
copy
12521253
}

0 commit comments

Comments
 (0)