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

Incompatibility of borrowing with any type in function arguments #73525

Open
rofle100lvl opened this issue May 8, 2024 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@rofle100lvl
Copy link

Description

No response

Reproduction

protocol K {
    var a: Int { get }
}

protocol B {
    init(k: any K)
}

struct A: B {
    let a: Int
    
    init(k: borrowing K) {
        self.a = k.a
    }
}

Expected behavior

When using the borrowing operator with a function argument of type any pointing to a protocol, the compiler should successfully parse and handle this combination

Environment

Apple Swift version 6.0-dev (LLVM 7b8e6346027d2b1, Swift 763421c)
Target: arm64-apple-macosx14.0

swift 5.10 as well

Additional information

Now we get compile error: "Usage of no-implicit-copy value that the compiler can't verify. This is a compiler bug. Please file a bug with a small example of the bug"

@rofle100lvl rofle100lvl added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 8, 2024
@tbkka
Copy link
Contributor

tbkka commented May 8, 2024

CC: @kavon

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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

2 participants