Created
September 8, 2016 13:12
-
-
Save ole/f33d64c06ca4517261c3fdab67830b4e to your computer and use it in GitHub Desktop.
Compiler segmentation fault in Xcode 8 GM using ExpressibleByArrayLiteral
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} | |
} |
@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
If you need a workaround for the time being, this seems to compile fine:
The problem seems to be related to the inline instantiation of the elements array.