-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Improved error handling for composed property wrapper mismatches #36732
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
Improved error handling for composed property wrapper mismatches #36732
Conversation
9d4b447
to
ee228a4
Compare
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.
Overall looks great! I have left a couple comments about documentation and code but logic-wise this is on point.
Thank you so much! I really appreciate your comments I will definitely go back and implement the changes you suggest :) |
015219c
to
36ed399
Compare
bae7b89
to
7e0ca2c
Compare
417a589
to
349a5f5
Compare
23746db
to
f3c7592
Compare
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.
A few more small changes.
lib/Sema/CSDiagnostics.cpp
Outdated
auto elt = locator->castLastElementTo<LocatorPathElt::WrappedValue>(); | ||
|
||
emitDiagnostic(diag::composed_property_wrapper_mismatch, | ||
resolveType(getFromType()), elt.getType(), getToType()); |
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.
Nit: getFromType()
would call resolve
internally so there is no need to call it again. But I think we need to call that for elt.getType()
?
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.
I agree. I did some investigating, and it turns out it's not required to use resolveType for any of the three function calls, so I went on and got rid of it all together, I hope that was okay.
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.
I think it is required on the element because element would get a type that might have type variables in it, so we'd end up printing _
instead of an actual type type variable was bound to.
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.
Oh that makes sense, I will fix that!
lib/Sema/CSSimplify.cpp
Outdated
|
||
case FixKind::AllowWrappedValueMismatch: { | ||
if (recordFix(fix)) return SolutionKind::Error; | ||
return SolutionKind::Solved; |
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.
Nit: formatting is incorrect here, I'd suggest to use a ternary - return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
|
Happy to help, thank you for making this work! |
Of course, it's been awesome to have the chance to work on this project, I've been learning so much! |
910b739
to
45b786e
Compare
d9cf79d
to
6034e35
Compare
231f175
to
aed8c6c
Compare
7920b64
to
e11f58d
Compare
ee9ece4
to
572a0c9
Compare
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.
Perfect!
@swift-ci please smoke test |
Awesome, thank you!!!! In that case then, in regards to @LucianoPAlmeida's comment, @xedin, should we make the removal of CTP_ComposedPropertyWrapper a project for another PR, or attempt to delete it in this one? |
Apparently I didn't press "Comment" :/ I think it's okay to clean that up separately. |
@swift-ci please smoke test Windows platform |
1 similar comment
@swift-ci please smoke test Windows platform |
@Strieker Looks like these changes regressed |
@Strieker you can run the validation tests locally by passing |
Or |
No problem, sounds good! Thank you :) |
|
No rush! You can try running /bin/sh from your terminal to see whether it would allow you to run commands again, if so - it’s something with your |
Thank you so, so much for this advice! Yes, I was assuming it was something having to do with my PATH, I will try your suggestions and see what happens, because I've been trying to change my PATH and I can't seem to get it working. |
… can recognize a composed property wrapper’s wrapped value type.
… wrapper mismatch in DiagnosticsSema.def and made changes to show the new composed property wrapper mismatch type diagnostic in both CSDiagnostics.cpp and CSDiagnostics.h.
…here the wrappedValue type of a property wrapper was determined and added necessary logic so that a constraint locator can recognize a composed property wrapper’s wrapped value type in CSFix.cpp, CSFix.h, and CSSimplify.cpp.
…est in property_wrappers.swift
…to improve error handling for composed wrapped value mismatches
… composed property werapper mismatches"
076be0c
to
72fc506
Compare
@swift-ci Please smoke test |
The purpose of this pull request is to remedy a confusing error associated with wrapped value type mismatches to give more context for the wrapped value type in the error message. So that when running this block of code:
the new error message for the above example would be
Should this change not have been made, the error would have looked like the following:
which is rather confusing.
NOTE: There is an existing diagnostic, called wrapped_value_mismatch that should be combine with this diagnostic, called composed_property_wrapper_mismatch. There are too many separate modifications to include in this PR in order to combine these two diagnostics, so that will be done in a separate PR.
Resolves:
https://bugs.swift.org/browse/SR-14130
Thank you @hborla for all of your help with this!