Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error when trying to use variadic generics for KeyPath #66125

Closed
mateusrodriguesxyz opened this issue May 25, 2023 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. parameter packs Feature → generics: Parameter packs type checker Area → compiler: Semantic analysis

Comments

@mateusrodriguesxyz
Copy link
Contributor

Description

I can't make the following code compile:

struct T {
    var p1: String
    var p2: Int
    var p3: Double
}

extension Array {
    
    func f<each P: Comparable>(_ keyPath: repeat KeyPath<Self.Element, each P>) {
//        repeat print(each keyPath) // Type of expression is ambiguous without more context
    }
    
}

let ts: [T] = []

ts.f(\.p1, \.p2, \.p3)

Steps to reproduce

Run the code above using the 2023-05-22 Snapshot

Expected behavior

print \T.p1 \T.p2 \T.p3

Environment

  • Swift compiler version info: 2023-05-22 Snapshot
  • Xcode version info: Xcode 14.3 Build version 14E222b
  • Deployment target: macOS 13.3.1
@mateusrodriguesxyz mateusrodriguesxyz added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 25, 2023
@xedin xedin added type checker Area → compiler: Semantic analysis parameter packs Feature → generics: Parameter packs and removed triage needed This issue needs more specific labels labels May 26, 2023
@hborla
Copy link
Member

hborla commented Jun 13, 2023

Fixed by #66589

@hborla hborla closed this as completed Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. parameter packs Feature → generics: Parameter packs type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants