Swift: Inconsistent behaviour between malformed ranges 3...2 and 3...1
| Originator: | richardb | ||
| Number: | rdar://17210471 | Date Originated: | 2014/06/07 |
| Status: | Duplicate of 16254937 (Open) | Resolved: | |
| Product: | Swift | Product Version: | |
| Classification: | Crash/Hang | Reproducible: | Always |
Summary:
In Swift, iterating over 3...2 exits as expected, whereas iterating over 3...1 loops infinitely.
Steps to Reproduce:
Run the attached playground file [not attached in OpenRadar], which contains:
import Foundation
var x = 0
for i in 3...2 { // expected never to run
println(i)
x = i
}
assert(x == 0) // never ran, as expected
x
x = 0
for i in 3...1 { // expected never to run but unexpectedly loops infinitely
println(i)
x = i
}
assert(x == 0) // never reached
Expected Results:
Expected both loops to not run their bodies and leave x unchanged at 0
Actual Results:
The second for loop ran infinitely (it may have stopped when it hit Int.max, but that's beside the point so I didn't test it).
Version:
Xcode Version 6.0 (6A215l)
OS X 10.9.3 build 13D65
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!