Missing diagnostic when capturing self in deinit Task #72893
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
concurrency
Feature: umbrella label for concurrency language features
Description
While there are many valid reasons to pass
self
as a parameter indeinit
, it is never valid to capture it in a Task. This is discussed by @mikeash in #62191 (comment):Doing so should generate a warning.
Reproduction
Expected behavior
As written, this code will crash, but no diagnostic will be printed in the
deinit
. If a[service]
capture is added to the Task, then this code is fine. It is tricky for developers to understand this subtle difference (self
does not even appear indeinit
).An ideal diagnostic would guide them to the proper capture. If no such capture can solve this, then the diagnostic should still indicate the problem.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: