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

Redo diagnostics for escaping captures and non-escaping parameter call restriction [5.1] #23923

Merged

Conversation

slavapestov
Copy link
Contributor

5.1 cherry-pick of #23878 and #23907.

I'm about to replace all of this with a SIL pass.
The new pass is based on existing asserts in DiagnoseStaticExclusivity.
They were compiled out in release builds and only checked for captures of
inout parameters. This patch converts the assertions into diagnostics and
adds checks for captures of non-escaping function values.

Unlike the Sema-based checks that this replaces, the new code handles
transitive captures from recursive local functions, which means certain
invalid code that used to compile will now be rejected with an error.

The new analysis also looks at the ultimate usages of a local function
instead of just assuming all local functions are escaping, which fixes
issues where the compiler would reject valid code.

Fixes a bunch of related issues, including:

- <rdar://problem/29403178>
- <https://bugs.swift.org/browse/SR-8546> / <rdar://problem/43355341>
- <https://bugs.swift.org/browse/SR-9043> / <rdar://problem/45511834>
…ibutes

Some diagnostics got worse, but I think the reduction in compiler complexity
is worth it, and copy-and-pasting Swift 2 code is not likely to produce great
results anyway.

Also, this corrects an oversight where we did not reject @pseudogeneric on
function types in AST parsing.
This fixes a test involving transitive captures of local functions,
as well as an infinite recursion possible with the old code.

Fixes <rdar://problem/34496304>.
@slavapestov slavapestov changed the title Noescape diagnostics 5.1 Redo diagnostics for escaping captures and non-escaping parameter call restriction [5.1] Apr 10, 2019
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d848d12

@slavapestov
Copy link
Contributor Author

@swift-ci Please test macOS

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@Demerro
Copy link

Demerro commented Nov 16, 2023

#69911

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