Skip to content
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

Remove an old diagnostic for 'var' in param position #10709

Merged
merged 1 commit into from
Jun 29, 2017

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jun 29, 2017

Using the attribute in this position is a relic from the Swift 2
days, and fixing it required letting invalid code fall through to
Sema instead of being diagnosed in Parse proper. Treat 'var'
in this position like 'let' by simply offering to remove it
instead of extracting it into a separate variable.

This simplifies our model by making the mapping between parsed parameter specifiers and parameter declaration specifiers one-to-one. In a future commit, these two representations will merge.

This is currently blocking #10695.

Using the attribute in this position is a relic from the Swift 2
days, and fixing it required letting invalid code fall through to
Sema instead of being diagnosed in Parse proper.  Treat 'var'
in this position like 'let' by simply offering to remove it
instead of extracting it into a separate variable.
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 29, 2017

@swift-ci please smoke test and merge

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 29, 2017

Going to file an SR (starter bug?) about improving this diagnostic a different way. In addition to @jrose-apple's idea to enqueue this diagnostic and waiting until we see the in of a closure to try the extraction, we could also just do what we do for parse and offer to stick an inout on the type in addition to removing the var specifier if we're in function position or we have a type ascription.

@swift-ci swift-ci merged commit 04bc382 into swiftlang:master Jun 29, 2017
@CodaFi CodaFi deleted the a-touch-of-varnish branch June 29, 2017 21:35
@jrose-apple
Copy link
Contributor

I don't think people who write var on a parameter actually mean inout. They just want to do the C thing of using it as a temporary variable as well.

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