Skip to content

Commit b075960

Browse files
authored
Fatal error replacing identified elements with invalid ids (#368)
* Fatal error replacing identified elements with invalid ids Fixes #366. * cleanup * fix
1 parent adf5024 commit b075960

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
@@ -119,6 +119,17 @@ where ID: Hashable {
119119
"""
120120
)
121121
}
122+
if newValue![keyPath: self.id] != id {
123+
fatalError(
124+
"""
125+
Can't update element at identifier \(id) with element having mismatched identifier \
126+
\(newValue![keyPath: self.id]).
127+
128+
If you would like to replace the element with identifier \(id) with an element with a \
129+
new identifier, remove the existing element and then insert the new element, instead.
130+
"""
131+
)
132+
}
122133
self.dictionary[id] = newValue
123134
}
124135
}

0 commit comments

Comments
 (0)