# Mysterious syntax in closure head

**URL:** <https://forums.swift.org/t/mysterious-syntax-in-closure-head/87523>\
**Category:** Using Swift\
**Tags:** closure\
**Created:** [June 20, 2026, 12:17am UTC](https://forums.swift.org/t/mysterious-syntax-in-closure-head/87523 "2026-06-20T00:17:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibex](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ibex/32/30439_2.png) [@ibex](https://forums.swift.org/u/ibex)\
**Post date:** [June 20, 2026, 12:17am UTC](https://forums.swift.org/t/mysterious-syntax-in-closure-head/87523/1 "2026-06-20T00:17:58Z")

</div>

I have stumbled on a mysterious syntax, which I don't understand.

Given

```swift
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.

```swift
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)`.

---

<div class="post-metadata">

**Author:** ![jamieQ](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jamieq/32/5117_2.png) [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Post date:** [June 20, 2026, 2:04am UTC](https://forums.swift.org/t/mysterious-syntax-in-closure-head/87523/2 "2026-06-20T02:04:08Z")

</div>

I think this is just a fun little parser quirk when actor annotations are used in a closure signature, since you'll get an error if you try to do that sort of thing in other positions. This was [reported](https://github.com/swiftlang/swift/issues/76540) a while back. The contents of the annotation parameter don't seem to make it into the parser or AST dump, so I'm assuming they're just ignored (though have not checked).

---

<div class="post-metadata">

**Author:** ![jamieQ](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jamieq/32/5117_2.png) [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Post date:** [June 20, 2026, 2:23pm UTC](https://forums.swift.org/t/mysterious-syntax-in-closure-head/87523/3 "2026-06-20T14:23:39Z")

</div>

```swift
typealias Reply = @MainActor(
  "In retrospect I realize I could have replied to the question like this 😉"
) () -> Void

```
