-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Diagnostics] Improve keypath diagnostic when cannot be inferred by context #31671
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
[Diagnostics] Improve keypath diagnostic when cannot be inferred by context #31671
Conversation
08466d9 to
8708374
Compare
|
@swift-ci please test |
64981c1 to
8ba94f9
Compare
d64bb42 to
5e881bc
Compare
xedin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this, @LucianoPAlmeida!
Couple of thoughts:
-
I think we should split this into two separate PRs, one for contextual stuff and other one for
keyPath:overload. -
Regarding
keyPath:- I think we can do better in this case and instead of saying
maybewe could actually verify thatkeyPath:overload choice works (good that it doesn't have to be a declaration :)) and suggest addingkeyPath:label.
- I think we can do better in this case and instead of saying
-
Regarding root/value inference failure:
- Is it any different from a regular inability to infer generic arguments?
- I think we should add a special diagnostic about
AnyKeyPathwhich state that it doesn't
provide enough contextual information to allow root type to be inferred implicitly
(because its root type isAny). That should help resolve at least some confusion here... - Could we suggest a fix-it in this case to specify
<#Root#>before a leading dot ?
Sure! Let's handle contextual first here then :)
Noted :)
I didn't thought about that, perhaps there is no difference...
I'll work on those, thanks @xedin :) |
I agree that we can tailor diagnostic messages but I think emission of the fix/diagnostic should be based on what we do for generic parameters. |
ce42050 to
34f40a8
Compare
34f40a8 to
16f1fd2
Compare
|
I was accidentally concurrently looking into this issue. From what I gather, this PR is now resolving the more general issue with key path types not being inferred from context, but not the issue of the |
Initially, it was trying to handle both, but I just remove the commit since @xedin suggested split in two PRs, will do a follow up as soon as this one lands :) |
|
@LucianoPAlmeida, I can't see the removed commits, but please take a peak at #31716, I imagine it is something similar? |
|
I'm a bit confused as to what's going to happen here? Are we merging Artem's PR or this one? I can't comment on the implementation but I think the diagnostic looks good. 👍 @swift-ci please test |
|
Build failed |
@varungandhi-apple We decided to split this PR into two parts contextual inference issues, and subscript fixes as a follow-up. So we let this one only to solve contextual issues and planning a follow up for the keyPath label... but coincidentally the second part is already handled by Artem's PR :) |
|
Build failed |
16f1fd2 to
9240366
Compare
|
I think Artem's covers PR the whole scope of the SR, so I removed the test cases related and will let this be only contextual stuff :) |
|
@LucianoPAlmeida I think it's |
9240366 to
7c19460
Compare
85e1eed to
9b422b0
Compare
9b422b0 to
9f5c113
Compare
|
@swift-ci please smoke test |
Improving the diagnostics when the key path type can't be inferred by context. e.g.
let _ : AnyKeyPath = \.xcc @xedin @hborla @varungandhi-apple :)