-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[6.0] [SE-0365] Fix issue where implicit self was unexpectedly disallowed in nested closures #73482
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…n nested closures
@swift-ci please test |
Hi @hborla, are you the best person to review this Swift 6 release PR? |
hborla
approved these changes
May 20, 2024
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.
Yes, thank you for fixing this!
@swift-ci please test |
@swift-ci please test Linux |
Thanks @hborla! Is this ready to be merged? |
Yep! |
slavapestov
added a commit
to slavapestov/swift
that referenced
this pull request
Jun 6, 2024
This fixes a regression from swiftlang#73482. Fixes rdar://problem/129255769.
slavapestov
added a commit
to slavapestov/swift
that referenced
this pull request
Jun 6, 2024
This fixes a regression from swiftlang#73482. Fixes rdar://problem/129255769.
slavapestov
added a commit
to slavapestov/swift
that referenced
this pull request
Jun 6, 2024
This fixes a regression from swiftlang#73482. Fixes rdar://problem/129255769.
ktoso
pushed a commit
to ktoso/swift
that referenced
this pull request
Jun 14, 2024
This fixes a regression from swiftlang#73482. Fixes rdar://problem/129255769.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
self
required in nested non-escaping closure #69911Explanation
This PR fixes issues related to SE-0365 and SE-0269 where the following code would unexpectedly fail to compile:
Scope
This change fixes several bugs related to SE-0365 and SE-0269. This bug fixes are important usability improvements to using nested closures, and match the expected behavior documented in those proposals.
Most relevant to Swift 6, this change also includes other minor bug fixes that are source breaking, where invalid code was previously allowed to compile. Examples include:
All of these examples are supposed to be rejected, but are currently accepted. This PR fixes those issues by making them emit a warning in Swift 5 mode, and be an error in Swift 6 mode.
If we don't land this change in Swift 6, we won't be able to fully fix those issues until the next major language mode.
Risk
The main risk is that this change could unintentionally introduce a regression in edge cases that we have not found yet. If there are regressions and we don't catch them before the release of Swift 6, we may not be able to fix the regression until Swift 7 (if the bug fix is source breaking, e.g. because the bug accidentally permits code that should be rejected). The best mitigation approach here is thorough testing:
Testing
We have extensively tested this change in both the Swift 5 and Swift 6 language modes. We added a large number of new test cases for basically every combination of nested closure varieties that we could think of. @hamishknight in particular was very helpful in coming up with even more cases that needed test coverage.
In addition to these new tests, all of the existing tests pass, including the source compatibility suite.
Reviewers
Please review:
Thanks!