-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresstandard libraryArea: Standard library umbrellaArea: Standard library umbrella
Description
Description
I am getting this warning with Version 14.1 (14B47b):
actor Test {
@TaskLocal static var local: Int?
func run() async {
await Self.$local.withValue(42) { // ⚠️
await work()
}
}
func work() async {
print("Hello \(Self.local ?? 0)")
}
}
await Test().run()warning: non-sendable type '() async throws -> ()' exiting actor-isolated context in call to non-isolated instance method 'withValue(_:operation:file:line:)' cannot cross actor boundary
Steps to reproduce
- copy the above code into a file
test.swift - run
swift -warn-concurrency test.swift
Expected behavior
The code should not produce a warning if it is legal code.
Environment
- swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
- Target: x86_64-apple-macosx13.0
- Xcode 14.1, Build version 14B47b
Additional context
Mentioned on Swift forum.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresstandard libraryArea: Standard library umbrellaArea: Standard library umbrella