Skip to content

Commit 0083f52

Browse files
committed
[stdlib] fix Array.replaceSubrange for incorrect with: count
1 parent 2759ad3 commit 0083f52

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

stdlib/public/core/ArrayBufferProtocol.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,12 @@ extension _ArrayBufferProtocol {
168168

169169
// place the values into the hole we created
170170
var place = holeStart
171-
for element in newValues {
172-
place.initialize(to: element)
171+
var i = newValues.startIndex
172+
while place < holeEnd {
173+
place.initialize(to: newValues[i])
173174
place += 1
175+
newValues.formIndex(after: &i)
174176
}
177+
_expectEnd(of: newValues, is: i)
175178
}
176179
}

0 commit comments

Comments
 (0)