Skip to content

Commit 0e15183

Browse files
authored
Merge pull request #3495 from rudkx/fix-ordered-compare-of-optional
2 parents 83fee42 + 599ab76 commit 0e15183

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/public/SDK/Foundation/IndexSet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
349349
///
350350
/// - parameter range: The range of integers to include.
351351
public func indexRange(in range: Range<Element>) -> Range<Index> {
352-
if range.isEmpty {
352+
guard !range.isEmpty, let first = first, let last = last else {
353353
let i = _index(ofInteger: 0)
354354
return i..<i
355355
}
356-
356+
357357
if range.lowerBound > last || (range.upperBound - 1) < first {
358358
let i = _index(ofInteger: 0)
359359
return i..<i

0 commit comments

Comments
 (0)