Skip to content

Instantly share code, notes, and snippets.

@dkyowell
Last active July 1, 2024 00:25
Show Gist options
  • Save dkyowell/1d6fd9ea5406c86792387abd0dde78d0 to your computer and use it in GitHub Desktop.
Save dkyowell/1d6fd9ea5406c86792387abd0dde78d0 to your computer and use it in GitHub Desktop.
Strange Swift 6 Compiler Behavior
import Foundation
import AVFoundation
// Using Xcode Version 16.0 beta (16A5171c), Swift 6 language mode.
// This compiles.
actor GoodActor {
var value = 0
func test() {
value = 1
let layer = AVCaptureVideoPreviewLayer()
Task {
value = 2
layer.session = AVCaptureSession()
}
}
}
// This raises a compiler error.
actor BadActor {
var value = 0
func test() {
value = 1
let layer = AVCaptureVideoPreviewLayer()
Task {
/* value = 2 */
layer.session = AVCaptureSession()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment