Skip to content

Commit 43df2ad

Browse files
stephencelismluisbrown
authored andcommitted
Fatal error replacing identified elements with invalid ids (#368)
* Fatal error replacing identified elements with invalid ids Fixes #366. * cleanup * fix
1 parent 6220382 commit 43df2ad

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/ComposableArchitecture/SwiftUI/IdentifiedArray.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ where ID: Hashable {
121121
"""
122122
)
123123
}
124+
if newValue![keyPath: self.id] != id {
125+
fatalError(
126+
"""
127+
Can't update element at identifier \(id) with element having mismatched identifier \
128+
\(newValue![keyPath: self.id]).
129+
130+
If you would like to replace the element with identifier \(id) with an element with a \
131+
new identifier, remove the existing element and then insert the new element, instead.
132+
"""
133+
)
134+
}
124135
self.dictionary[id] = newValue
125136
}
126137
}

0 commit comments

Comments
 (0)