Avatar
Avatar
Iceman
@swift-6.2-dev -swift-version 6 func doSomething(_: @Sendable () -> ()) { } func foo(nonsendable: Any) { @MainActor func track() { doSomething { Task { @MainActor in track() } } print(nonsendable) } }
exit status 1 with stderr:<stdin>:9:17: error: capture of 'track()' with non-Sendable type '() -> ()' in a '@Sendable' closure [#SendableClosureCaptures] 7 | doSomething { 8 | Task { @MainActor in 9 | track() | |- error: capture of 'track()' with non-Sendable type '() -> ()' in a '@Sendable' closure [#SendableClosureCaptures] | `- note: a function type must be marked '@Sendable' to conform to 'Sendable' 10 | } 11 | } [#SendableClosureCaptures]: <https://docs.swift.org/compiler/documentation/diagnostics/sendable-closure-captures>