-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Improve diagnostics for non-escaping function types #15383
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
Conversation
/cc @rudkx I think this is better but unfortunately there is no way to relate type to it's declaration (if any) so I opted out just calling everything 'value' but in the future we can split into parameter/value cases. |
@@ -2805,6 +2805,11 @@ ERROR(assigning_noescape_to_escaping,none, | |||
ERROR(general_noescape_to_escaping,none, | |||
"using non-escaping parameter %0 in a context expecting an @escaping closure", | |||
(Identifier)) | |||
ERROR(assigning_noescape_to_generic_param,none, | |||
"assigning non-escaping value to %0 may allow it to escape", |
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.
We're not assigning when we emit the diagnostic -- there's no assignment expression. I think "converting" still makes sense
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.
Sure, thanks! Do you think it's worth adding "generic param" before %0
as well?
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.
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.
Done! Changed assigning
to converting
.
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.
LGTM, thanks for taking care of this!
@swift-ci please smoke test |
@swift-ci please smoke test Linux platform |
@swift-ci please smoke test macOS platform |
@@ -2805,6 +2805,11 @@ ERROR(assigning_noescape_to_escaping,none, | |||
ERROR(general_noescape_to_escaping,none, | |||
"using non-escaping parameter %0 in a context expecting an @escaping closure", | |||
(Identifier)) | |||
ERROR(converting_noescape_to_generic_param,none, | |||
"converting non-escaping value to %0 may allow it to escape", | |||
(Identifier)) |
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.
if you make this a Type, you can combine the two diagnostics and just pass in the Any type in the second case.
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.
Ah interesting, somehow I haven't realized that archetype is also a 'type' :)
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.
Done!
Allow certain bindings and conversions involving non-escaping function types to succeed in "diagnostic" mode to gather fixes and diagnose such problems better, expecially related to conversions to 'Any' and generic parameters. Resolves: rdar://problem/38648760
@swift-ci please clean smoke test |
Allow certain bindings and conversions involving non-escaping
function types to succeed in "diagnostic" mode to gather fixes
and diagnose such problems better, expecially related to
conversions to 'Any' and generic parameters.
Resolves: rdar://problem/38648760