You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is as currently designed. KeyPaths aren't covariant, and appending only succeeds when the root type of the RHS matches the value type of the LHS exactly. With subscript support you would be able to write \A.[keyPath: a]?[keyPath: b] to chain these paths together.
What I'm really interested in is breaking ab1 into its parts, a and b.
Since there's not currently possible, I enumerate all the available KeyPaths and append them to find which combination combines to make ab1. But the inability to append these leaves me in a real pickle.
It seems like I should be able to append these two things, even without proper covariance. The inability to create ab2 from its parts is a real shortcoming.
If you want to break key paths into their components, that's something I feel key paths ought to eventually support directly. The object layout is not finalized, but the current layout is described here, which might allow you to experiment ahead of our ability to design proper APIs for this: https://github.com/apple/swift/blob/master/docs/ABI/KeyPaths.md Optional chains are fundamentally somewhat special because, as key path components, they have non-local influence over the behavior of the entire following chain, since it short-circuits further evaluation if the component is nil.
Since I'm also interested in this kind of stuff for ZeeQL, I started to try the decoding thing. I didn't finish it because I noticed it is not quite what I want (the string names of the path). But in the case someone wants to play with the (completely unfinished, super hacky, probably quite incorrect) thing: https://gist.github.com/helje5/e5e6e50af60d0ee62169ac815f60d6d3
Environment
Xcode 9.0.0 ß5
Apple Swift version 4.0 (swiftlang-900.0.59 clang-900.0.34.2)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: c160af841d3bf69ec27401edfd434563
Issue Description:
This code doesn't work:
It yields this error:
There doesn't be any way to append
b
toa
to recreateab1
.It's not just type inference. Attempting this with
AnyKeyPath
results in anil
value.The text was updated successfully, but these errors were encountered: