From 41b32978b7012931c51ad238c8a5daac5099eb36 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 13:42:03 +0100 Subject: [PATCH] Don't panic, when merging identical full objects --- crates/fj-kernel/src/partial/maybe_partial.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/maybe_partial.rs b/crates/fj-kernel/src/partial/maybe_partial.rs index 5b9cee73c..ce1ea530c 100644 --- a/crates/fj-kernel/src/partial/maybe_partial.rs +++ b/crates/fj-kernel/src/partial/maybe_partial.rs @@ -67,8 +67,14 @@ impl MaybePartial { /// Merge this `MaybePartial` with another of the same type pub fn merge_with(self, other: impl Into) -> Self { match (self, other.into()) { - (Self::Full(_), Self::Full(_)) => { - panic!("Can't merge two full objects") + (Self::Full(a), Self::Full(b)) => { + if a.id() != b.id() { + panic!("Can't merge two full objects") + } + + // If they're equal, which they are, if we reach this point, + // then merging them is a no-op. + Self::Full(a) } (Self::Full(full), Self::Partial(_)) | (Self::Partial(_), Self::Full(full)) => Self::Full(full),