We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Swift 5.2
md5: c7e6a520962d91be27623d1bf56a50ce
Issue Description:
The following code fails to compile in a playground:
struct Identified<A>: Identifiable { var value: A var id: AnyHashable init<B: Hashable>(_ value: A, by hashable: (A) -> B) { self.value = value self.id = hashable(value) } // init<B: Hashable>(_ value: A, by hashable: KeyPath<A, B>) { // self.value = value // self.id = value[keyPath: hashable] // } } Identified(1, by: \.self)
cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int) -> B'
The commented-out overload seems to be required. When commented-in, the code behaves as expected.
In general, the "self" key path doesn't seem to work in expected situations. For example:
[Optional(1), 2, 3].compactMap(\.self)
error: type of expression is ambiguous without more context
The text was updated successfully, but these errors were encountered:
@swift-ci create
Sorry, something went wrong.
Duplicate of https://bugs.swift.org/browse/SR-12897
I think this has been fixed by combination of the following PRs - #69742, #69742. All of the expressions mentioned in the description now type-check.
Please use the latest main compiler snapshot to verify and re-open.
No branches or pull requests
Environment
Swift 5.2
Additional Detail from JIRA
md5: c7e6a520962d91be27623d1bf56a50ce
Issue Description:
The following code fails to compile in a playground:
The commented-out overload seems to be required. When commented-in, the code behaves as expected.
In general, the "self" key path doesn't seem to work in expected situations. For example:
The text was updated successfully, but these errors were encountered: