Skip to content

[SIL Diagnostics] Improve diagnostics for capture of inout values in escaping autoclosures. #31139

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

Conversation

ravikandhadai
Copy link
Contributor

Currently, when an inout or mutating self is passed to an escaping, autoclosured parameter, the error message looks as follows:

foo(x) 
  error: escaping closure captures 'inout' parameter 'x'
  note: captured here

The error message refers to a closure even though there is no closure is in the source code. This PR improves the error message and makes the note more actionable for autoclosures:

foo(x) 
  error: escaping autoclosure captures 'inout' parameter 'x'
  note: pass a copy of 'x'

rdar://problem/60551844

within escaping autoclosures.

<rdar://problem/60551844>
@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test

@ravikandhadai ravikandhadai self-assigned this Apr 19, 2020
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a2d38f6

@ravikandhadai
Copy link
Contributor Author

@swift-ci Please smoke test Linux Platform

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

LGTM

@ravikandhadai ravikandhadai merged commit 1c2bc06 into swiftlang:master Apr 20, 2020
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