/ swift

Swift Compiler Error when using Generics and nested functions, Command failed due to signal: Segmentation fault: 11

The problem:

The following code is causing a compiler crash when compiled with Swift 3 and Xcode 8:

import Foundation

public typealias IntCompletion = (Int) -> Void
public typealias FetchIntBlock = (IntCompletion) -> Void

class ATSwiftTest<T: NSURL>: NSObject {

    var fetchIntBlock: FetchIntBlock

    override init() {
        fetchIntBlock = { (aFunc) in }


By the process of elimination we were able to figure out that the problem is caused by the nested function declaration.

var fetchIntBlock: FetchIntBlock

The code crashes a Playground compiler as well.


If we make the fetchIntBlock var private the code compiles just fine.

It would still be nice for the var to be public.