Xcode6-Beta (6A215l): Swift Range syntax with negative values
| Originator: | me | ||
| Number: | rdar://17156190 | Date Originated: | 04-Jun-2014 11:46 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode6-Beta (6A215l) |
| Classification: | Serious Bug | Reproducible: | Always |
This is a duplicate of rdar://17154140
var range = -1...1
var reversedRange = ReverseRange(range: range)
var createdAsReverse = 1...(-1)
for i in reversedRange {
println(i)
}
//prints 1, 0, 0, -1
for i in createdAsReverse {
println(i)
}
//prints 1, 2, 3.... in an infinite loop
One would except that the two ranges created in this way to behave similarly.
Additionally there is no way to create a range where the end of the range is less than the beginning. One would expect that the 1...-1 would either work the same as reversing 1...-1, or to trap when trying to create a range where the end is less than the beginning.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!