-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
SILactor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.closuresFeature: closuresFeature: closurescompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresexpressionsFeature: expressionsFeature: expressionsnil-coalescing operatorFeature → operators: The nil-coalescing operator `??`Feature → operators: The nil-coalescing operator `??`operatorsFeature: operatorsFeature: operatorstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected warningBug: Unexpected warningBug: Unexpected warning
Description
Description
I have a case where I can use an if/else block, but can't use ?? without a data race warning
Reproduction
// This works
cbCentralManager.retrieveConnectedPeripherals(withServices: services.map { $0.uuid })
.map {
if let peripheral = ($0.delegate as? Peripheral) {
return peripheral
} else {
return Peripheral(cbPeripheral: $0, queue: self.queue)
}
}
// This causes: 'self'-isolated '$0' is captured by a actor-isolated closure. actor-isolated uses in closure may race against later nonisolated uses
cbCentralManager.retrieveConnectedPeripherals(withServices: services.map { $0.uuid })
.map { ($0.delegate as? Peripheral) ?? Peripheral(cbPeripheral: $0, queue: self.queue) }
Expected behavior
The ?? case would not cause a data race warning.
Environment
Xcode Version 16.0 beta 2 (16A5171r) in Swift 6 language mode
Additional information
No response
Metadata
Metadata
Assignees
Labels
SILactor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.closuresFeature: closuresFeature: closurescompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresexpressionsFeature: expressionsFeature: expressionsnil-coalescing operatorFeature → operators: The nil-coalescing operator `??`Feature → operators: The nil-coalescing operator `??`operatorsFeature: operatorsFeature: operatorstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected warningBug: Unexpected warningBug: Unexpected warning