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
Accessing computed property sometimes causes unexpected consume of borrowed value #73292
Comments
I noticed that the first example's struct Example {
protocol Proto {
var count: Int { get }
}
func takeProto(_ p: borrowing some Proto) -> Int {
{ p.count }()
}
} However, when I tried the same trick with the latest 6.0-dev ( Full
|
Description
I've found two cases of values getting consumed when reading computed properties, and they seem like they're not correct behavior based on my reading of SE-0377 and SE-0390.
borrowed some Proto
parameter calling a getter on the borrowed valueborrowing
method in astruct A<T>
that has a stored propertyv: T
Reproduction
Case 1: borrowed parameter with opaque type
Result is
Interestingly using
p: borrowing any Proto
leads to a different error. Should I make another issue for this as the error suggests?Case 2: borrowing method in a generic struct with stored property of generic type
Expected behavior
Case 1
Expected no error
Case 2
Expected no error, like in the following cases that compile fine:
Environment
Additional information
Forum post
The text was updated successfully, but these errors were encountered: