Type inference-related compiler segfault

This little program will segfault the compiler (Xcode 7 beta 6):

let a = [1, 2, 3]
let b = a.map { $0 % 2 == 0 ? $0 : nil }
print(b)


Helping it with the type inference makes it compile and work as expected:

let a = [1, 2, 3]
let b : [Int?] = a.map { $0 % 2 == 0 ? $0 : nil }
print(b)


#22555889

Answered by ChrisLattner in 48429022

Thanks! This is indeed a bug and will be fixed in a subsequent update to the compiler.


-Chris

FWIW in 1.2 swiftc returns this error:


error: cannot invoke 'map' with an argument list of type '((_) -> _)'
Accepted Answer

Thanks! This is indeed a bug and will be fixed in a subsequent update to the compiler.


-Chris

Tested with Xcode 7.1 beta 2, which gives an understandable error message for the first example. Problem solved.

Type inference-related compiler segfault
 
 
Q