Swift playground code crash

Originator:sartak
Number:rdar://17117521 Date Originated:2014-06-03
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6 beta 1 (Version 6.0 (6A215l))
Classification:crash / hang / data loss Reproducible:always
 
Summary:
I was writing a binary search in Swift without looking at a reference, to see how well the new interactive environment works.

Steps to Reproduce:
1. Open Xcode
2. File -> New -> File
3. Playground
4. Replace code with the following:



func binarySearch(needle: Int, haystack: Int[]) -> Int? {
    func inner(low: Int, high: Int) -> Int? {
        if low > high {
            return nil
        }

        let index = (high + low) / 2
        let guess = haystack[index]
        if guess == needle {
            return index
        }
        else if (needle > guess) {
            return inner(low, index-1)
        }
        else {
            return inner(index+1, high)
        }
    }
    return inner(0, haystack.count - 1)
}

/*
binarySearch(0, [1, 2, 3, 4, 5])
binarySearch(1, [1, 2, 3, 4, 5])
binarySearch(2, [1, 2, 3, 4, 5])
binarySearch(3, [1, 2, 3, 4, 5])
binarySearch(4, [1, 2, 3, 4, 5])
binarySearch(5, [1, 2, 3, 4, 5])
binarySearch(6, [1, 2, 3, 4, 5])
binarySearch(-100, [1, 2, 3, 4, 5])
binarySearch(100, [1, 2, 3, 4, 5])
*/


Expected Results:
Xcode doesn't crash :)

Actual Results:
Xcode crashes, and the code that was pasted in is was not saved (it reverts to the default Playground template code)

Version:
Xcode 6 beta 1 (Version 6.0 (6A215l))
OS X Mavericks 10.9.3

Notes:


Configuration:
Late 2013 retina MBP 13"

Attachments:

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!