Last active
July 1, 2024 00:25
-
-
Save dkyowell/1d6fd9ea5406c86792387abd0dde78d0 to your computer and use it in GitHub Desktop.
Strange Swift 6 Compiler Behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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