Skip to content

Instantly share code, notes, and snippets.

@ole
Created September 8, 2016 13:12
Show Gist options
  • Save ole/f33d64c06ca4517261c3fdab67830b4e to your computer and use it in GitHub Desktop.
Save ole/f33d64c06ca4517261c3fdab67830b4e to your computer and use it in GitHub Desktop.
Compiler segmentation fault in Xcode 8 GM using ExpressibleByArrayLiteral
// Save this to stack.swift, then run
//
// $ xcrun swift stack.swift
//
// Does it compile or does the compiler segfault?
struct Stack<Element> {
var elements: [Element] = []
}
extension Stack: ExpressibleByArrayLiteral {
init(arrayLiteral elements: Element...) {
self.elements = elements
}
}
@ole
Copy link
Author

ole commented Sep 8, 2016

@chrisfsampaio Ah, that's interesting, thanks. Another workaround is to explicitly call self.init from the extension:

struct Stack<Element> {
    var elements: [Element] = []
}

extension Stack: ExpressibleByArrayLiteral {
    init(arrayLiteral elements: Element...) {
        self.init(elements: elements)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment