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

[SR-9840] @convention function conversions spuriously triggering escape analysis #52254

Open
hamishknight opened this issue Feb 1, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-9840
Radar None
Original Reporter @hamishknight
Type Bug
Environment

Swift version 5.0-dev (LLVM 3d732ae554, Clang 38ef19dd1f, Swift 87b66e7)
Target: x86_64-apple-darwin18.2.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 4925c6ba1fef8aedfe285804613ccbc3

relates to:

  • SR-9839 @convention function conversions unreliably fail when type variables are introduced

Issue Description:

Unsure if this is the same issue as [SR-9839] or not, but filing separately just in case it isn't.

The following doesn't compile:

func bar(_ x: @convention(block) () -> Void) {}

func id<T>(_ x: T) -> T {
  return x
}

var qux: () -> Void = {}

bar(qux)
bar(id(qux))
bar(id(id(qux))) // error: Converting non-escaping value to 'T' may allow it to escape

However it does compile if the @convention(block) is removed from bar's parameter.

@belkadan
Copy link
Contributor

belkadan commented Feb 1, 2019

I don't think that's legal to begin with. The closure's lifetime isn't guaranteed through the first call to id. cc aschwaighofer@apple.com (JIRA User), @rjmccall

@rjmccall
Copy link
Member

rjmccall commented Feb 1, 2019

Closures stored to global variables like that should be inferred as escaping closures.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants