Skip to content

[SR-14960] Try to detect if continuation is known to not be resumed and emit warning #57302

@typesanitizer

Description

@typesanitizer
Previous ID SR-14960
Radar rdar://problem/80995926
Original Reporter @typesanitizer
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: e84eb2c1f41a9810e0beb09fb30b42a4

Issue Description:

The following code pattern is incorrect.

var local: CheckedContinuation<Void, Never>?
withCheckedContinuation { cont in
  local = cont
}

I was confused why this created a hang, then after talking to John, I realized I need to store the continuation on an actor's property, that way, some other task can come along and (thanks to actor reentrancy) access the property, optionally do some work and then resume the continuation.

If possible, it would be nice to have a warning for this kind of code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions