Skip to content

Pack type inference fails for T == (repeat each A, U, repeat each B) #82403

Open
@AnthonyLatsis

Description

@AnthonyLatsis

Description

No response

Reproduction

struct Foo<T> {
  func pick<each A, Pick, each B>(_: Pick.Type) -> Pick
  where T == (repeat each A, Pick, repeat each B) {
    fatalError()
  }
}
let x = Foo<(String, Int, Bool)>()
let int: Int = x.pick(Int.self)
/Users/alatsis/desktop/test.swift:86:18: error: instance method 'pick' requires the types '(String, Int, Bool)' and '(repeat each A, Int, repeat each B)' be equivalent [types_not_equal_decl]
let int: Int = x.pick(Int.self)
                 ^
/Users/alatsis/desktop/test.swift:80:8: note: where 'T' = '(String, Int, Bool)', '(repeat each A, Pick, repeat each B)' = '(repeat each A, Int, repeat each B)' [where_requirement_failure_both_subst]
  func pick<each A, Pick, each B>(_: Pick.Type) -> Pick
       ^
/Users/alatsis/desktop/test.swift:86:18: error: generic parameter 'each A' could not be inferred [unbound_generic_parameter]
let int: Int = x.pick(Int.self)
                 ^
/Users/alatsis/desktop/test.swift:86:18: error: generic parameter 'each B' could not be inferred [unbound_generic_parameter]
let int: Int = x.pick(Int.self)
                 ^
/Users/alatsis/desktop/test.swift:80:8: note: in call to function 'pick' [note_call_to_func]
  func pick<each A, Pick, each B>(_: Pick.Type) -> Pick
       ^

Expected behavior

Success in unambiguous cases.

Environment

Swift version 6.2-dev (LLVM 8bcf2671393ccfb, Swift aee16d7)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itselfgenericsFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsswift 6.2type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions