-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself
Description
Previous ID | SR-985 |
Radar | None |
Original Reporter | @an0 |
Type | Bug |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: f3e4c0c6558ec266c5547d7f7e079fa3
Issue Description:
This code runs in playground but repl and swiftc reports error:
type 'Stack' nested in generic function 'foo' is not allowed
func foo() {
class Stack<Element> {
init() {
array = []
}
init(e: Element) {
array = [e]
}
init<S: Sequence where S.Iterator.Element == Element>(es: S) {
array = [Element](es)
}
var array: [Element]
func push(_ e: Element) {
array.append(e)
}
func push<S: Sequence where S.Iterator.Element == Element>(_ es: S) {
array.append(contentsOf: es)
}
func pop() -> Element? {
return array.popLast()
}
var isEmpty: Bool {
return array.isEmpty
}
}
func tailRecursive(_ stack: Stack<Int>) {
guard let i = stack.pop() else { return }
print(i)
stack.push(i + 1)
tailRecursive(stack)
}
tailRecursive(Stack(e: 0))
}
foo()
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself