-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaArea: Standard library umbrella
Description
Previous ID | SR-10299 |
Radar | None |
Original Reporter | gpambrozio (JIRA User) |
Type | Bug |
Environment
Playground running on XCode 10.2 GM
Additional Detail from JIRA
Votes | 0 |
Component/s | Standard Library |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 1658d7d4fcd057072ea901fa5d7d095b
Issue Description:
I noticed that if you have a partial range and you call relative(to🙂 with a collection that does not contain the range's specified bound you get a fatalError
This is a simple playground that shows the problem:
let emptyCollection = [Int]()
let nonEmptyCollection = (0..<20).map { $0 }
let arraySlice = nonEmptyCollection[5...]
let partialRangeFrom = 1...
let partialRangeUpTo = ..<1
let partialRangeThrough = ...1
partialRangeFrom.relative(to: emptyCollection)
partialRangeUpTo.relative(to: arraySlice)
partialRangeThrough.relative(to: arraySlice)
The playground will crash on the first relative(to🙂 call but if you comment that out it crashes on the next and so on.
I have found a simple fix for the issue and am submitting a pull request with the change and tests that would crash as it is now.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaArea: Standard library umbrella