-
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 itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarekey pathsFeature: key paths (both native and Objective-C)Feature: key paths (both native and Objective-C)optimized onlyFlag: An issue whose reproduction requires optimized compilationFlag: An issue whose reproduction requires optimized compilationoptional protocol requirementsFeature → protocol: optional protocol requirementsFeature → protocol: optional protocol requirementsswift 5.6
Description
Previous ID | SR-16076 |
Radar | None |
Original Reporter | @davedelong |
Type | Bug |
Environment
Xcode 13.3 and Xcode 13.2.1
Additional Detail from JIRA
Votes | 0 |
Component/s | swift |
Labels | Bug |
Assignee | @AnthonyLatsis |
Priority | Medium |
md5: 2b2d253ea8e84f4670e030c4b62dd6c5
Issue Description:
Given this code:
@objc protocol OptionalVar {
@objc optional var name: String { get }
}
extension NSObject: OptionalVar { }
let objects = [
NSObject(),
NSObject(),
NSObject()
] as Array<OptionalVar>
let names = objects.compactMap(\.name)
print("Names: \(names)")
This will build and run fine in debug mode (-Onone
), but the compiler crashes when in building in release mode (-O
).
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 softwarekey pathsFeature: key paths (both native and Objective-C)Feature: key paths (both native and Objective-C)optimized onlyFlag: An issue whose reproduction requires optimized compilationFlag: An issue whose reproduction requires optimized compilationoptional protocol requirementsFeature → protocol: optional protocol requirementsFeature → protocol: optional protocol requirementsswift 5.6