Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10299] RangeExpression's relative(to:) crashes on partial ranges #52699

Open
swift-ci opened this issue Apr 3, 2019 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2019

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.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 3, 2019

Comment by Gustavo Ambrozio (JIRA)

Pull request submitted: #23778

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant