Skip to content

[3.0 compat] Don't diagnose @escaping var-arg closures. #5217

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
Oct 11, 2016

Conversation

milseman
Copy link
Member

@milseman milseman commented Oct 10, 2016

• Explanation:  Var-arg closures are already escaping, so we typically want to issue
an error if @escaping is specified. But, we shipped a bug in 3.0 where they needed an explicit @escaping to function properly. Because we don’t expose sub-minor-version control, a library author cannot use escaping var-arg closure parameters in ways that are source-compatible with both 3.0 and 3.0.1. This is especially an issue at least during the period before a GM of 3.0.1.
• Scope of Issue: This affects only escaping closure var-arg parameters. Note that this will slightly worsen the QoI and developer experience when working with 3.0.1 and later in the Swift 3 family of versions. This is because having an extraneous @escaping, that is semantically irrelevant, would give the false impression that it is semantically meaningful. But, this is a corner case situation either way, and thus the confusion is limited in scope.
• Origination: Swift-3, when we added the noescape-by-default rule
• Risk: Very low, as we just skip emitting an error.
• Reviewed By:  Slava
• Testing: Added lit tests
• Directions for QA: none

Resolves SR-2907.

Var-arg closures are already escaping, so we typically want to issue
an error if @escaping is specified. To not do sure will confuse and
give a false impression on the un-annotated semantics and whether it
is needed. But, 3.0 shipped with a bug where we didn't consistently
apply the no-escape-by-default rule here, and thus it was semantically
meaningful (and needed).

In order to preserve source compatibility, albeit at the expense of
developers on versions 3.0.1 and later in the Swift 3 family, we
suppress the error if we see @escaping. Either way, this is a
relatively uncommon usage, so the confusion won't be too wide spread.

Var-arg closures are already escaping, so we typically want to issue
an error if @escaping is specified. To not do sure will confuse and
give a false impression on the un-annotated semantics and whether it
is needed. But, 3.0 shipped with a bug where we didn't consistently
apply the no-escape-by-default rule here, and thus it was semantically
meaningful (and needed).

In order to preserve source compatibility, albeit at the expense of
developers on versions 3.0.1 and later in the Swift 3 family, we
suppress the error if we see @escaping. Either way, this is a
relatively uncommon usage, so the confusion won't be too wide spread.
@milseman
Copy link
Member Author

@swift-ci please test

@slavapestov
Copy link
Contributor

LGTM, thanks.

@milseman milseman assigned ematejska and unassigned tkremenek Oct 11, 2016
@ematejska ematejska merged commit eb6e8a3 into swiftlang:swift-3.0-branch Oct 11, 2016
@milseman milseman deleted the 3_0_escaping branch April 7, 2017 22:38
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.

4 participants