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
[SR-9478] WriteableKeyPath with IUO crash #51940
Comments
Hi @jckarter! We ran into this one today. It has a pretty simple repro. |
@jckarter Looks like There is only one solution we find in this case which requires `currencyCode` to be force unwrapped, because `set` function type is - (WriableKeyPath<T, U>, U)` and we attempt `String` first based on type of `code`. `String?` could be attempted in this case but only if `String` where to fail, but it doesn't because there is a IUO involved. Unfortunately it doesn't seem like we could do much in this case from type-checker perspective, @rudkx Any ideas? |
It seems like this ought to work and the fact that it doesn't today is an artifact of some implementation choices. I took a quick look yesterday and it appeared that we were only attempting `String` for the type, but it seems like it would be reasonable to defer binding the type for the type variable until after we've selected a type for `Root` and determined the type of `currencyCode`. |
@rudkx Yes, it seems like there is an ordering problem for this example but I'm not sure what the sane rule for changing it might be:
In this case $T6 is worse than either $T1 and $T2. If we had a disjunction associated with $T4 earlier that would have helped, but is that possible? |
Environment
Xcode 10.1 (10B61)
Swift 4.2
Additional Detail from JIRA
md5: 615ff1c11387ed7d548c7b719f700cc6
Issue Description:
The following code crashes:
with the stack trace:
Two different things will fix it:
or
The text was updated successfully, but these errors were encountered: