Skip to content

[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

Merged
merged 1 commit into from
Mar 21, 2018

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Mar 20, 2018

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

@xedin xedin requested a review from rudkx March 20, 2018 21:41
@xedin
Copy link
Contributor Author

xedin commented Mar 20, 2018

/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",
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Contributor

@rudkx rudkx left a 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!

@xedin
Copy link
Contributor Author

xedin commented Mar 20, 2018

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Mar 20, 2018

@swift-ci please smoke test Linux platform

@xedin
Copy link
Contributor Author

xedin commented Mar 20, 2018

@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))
Copy link
Contributor

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.

Copy link
Contributor Author

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' :)

Copy link
Contributor Author

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
@xedin
Copy link
Contributor Author

xedin commented Mar 21, 2018

@swift-ci please clean smoke test

@xedin xedin merged commit 9f275ca into swiftlang:master Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants