-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
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 itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution
Description
Previous ID | SR-10308 |
Radar | None |
Original Reporter | dbeard (JIRA User) |
Type | Bug |
Environment
Xcode Version 10.2 (10E125) / Swift 5.0
macOS version 10.14.4 (18E226)
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, RunTimeCrash |
Assignee | None |
Priority | Medium |
md5: b46c020e08aba8bae2389a3ca0cb2b74
Issue Description:
The following code causes a crash at runtime, but compiles fine:
import UIKit
enum FooType {
case one
case two
}
typealias Permutation = () -> (Void)
@objcMembers
class CatalogItem: NSObject {
var t: FooType
var permutation: Permutation?
required init(t: FooType) {
self.t = t
}
}
@objcMembers
class Subclass: CatalogItem {
convenience init() {
self.init(t: .one)
self.permutation = { [weak self] in
print(self?.t)
}
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let s = Subclass() // EXC_BAD_ACCESS !
}
}
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 itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution