-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#62787
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 itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typesFeature: generic declarations and typesliteralsFeature → expressions: Literals such as an integer or string literalFeature → expressions: Literals such as an integer or string literalopaque typesFeature → types: opaque typesFeature → types: opaque typesswift 5.7type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inference
Description
Description
Generic parameter 'τ_0_0' could not be inferred.
Steps to reproduce
Open playgrounds and paste the following code:
import SwiftUI
enum Fruit {
case apple
case orange
var icon: (some View)? {
switch self {
case .apple: return Image(systemName: "applelogo")
case .orange: return nil
}
}
}
Expected behavior
No error. The "(some View)?" type should be acceptable since either of the return types are in line with it.
Environment
-
Swift compiler version info swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0 -
Xcode version info Xcode 14.2
Build version 14C18 -
Deployment target: N/A - swift playgrounds
Opening the issues here as per: #53242 (comment)
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 itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typesFeature: generic declarations and typesliteralsFeature → expressions: Literals such as an integer or string literalFeature → expressions: Literals such as an integer or string literalopaque typesFeature → types: opaque typesFeature → types: opaque typesswift 5.7type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inference