I have stumbled on a mysterious syntax, which I don't understand.
Given
func f (u: @MainActor @Sendable @escaping (Int) -> Int) async {
let v = await u (Int.random (in: 0..<1024))
print ("f (\(v)) =", Int.random (in: 0...v))
}
// Mysterious syntax: `(x: Fubar)`
//
await f {
@MainActor(x: Fubar) x in
Int.random (in: 0...x)
}
That code compiles, but what does (x: Fubar) mean in the closure's head?
In fact, I can replace x:Fubar with y + pi, z, g (x), w: T and the code still compiles.
await f {
@MainActor(y + pi, z, g (x), w: T) x in
Int.random (in: 0...x)
}
PS: I am using Xcode Version 26.5 (17F42).