Skip to content

Generic parameter 'τ_0_0' could not be inferred #63150

@ios-blacksmith

Description

@ios-blacksmith

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

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typesliteralsFeature → expressions: Literals such as an integer or string literalopaque typesFeature → types: opaque typesswift 5.7type checkerArea → compiler: Semantic analysistype inferenceFeature: type inference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions