# Cannot find 'weak' in scope on closure of a DispatchQue.async

**URL:** <https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819>\
**Category:** Using Swift\
**Tags:** weak, escapingclosure\
**Created:** [February 3, 2024, 9:32pm UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819 "2024-02-03T21:32:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![richoncode](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/richoncode/32/33891_2.png) [@richoncode](https://forums.swift.org/u/richoncode)\
**Post date:** [February 3, 2024, 9:32pm UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819/1 "2024-02-03T21:32:03Z")

</div>

let concurrentQueue = DispatchQueue(label: "concurrentQueue",  
qos: .background, attributes: .concurrent)  
concurrentQueue.async { [weak self] // Cannot find 'weak' in scope  
guard let self = self else { return }  
}

I verified the API is @escaping as one would suspect.

I'm sure I am missing some core concept, but my searches keep leading to no answers.

---

<div class="post-metadata">

**Author:** ![jlukas](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jlukas/32/317_2.png) [@jlukas](https://forums.swift.org/u/jlukas)\
**Post date:** [February 3, 2024, 9:44pm UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819/2 "2024-02-03T21:44:56Z")

</div>

You’re missing `in` after `[weak self]`.

---

<div class="post-metadata">

**Author:** ![richoncode](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/richoncode/32/33891_2.png) [@richoncode](https://forums.swift.org/u/richoncode)\
**Post date:** [February 4, 2024, 3:16am UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819/3 "2024-02-04T03:16:15Z")

</div>

Oh wow. time to step away from the code for a few hours!  
Thank you!

Is there a forum to suggest xcode error fix hints?

---

<div class="post-metadata">

**Author:** ![Pippin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pippin/32/24826_2.png) [@Pippin](https://forums.swift.org/u/Pippin)\
**Post date:** [February 4, 2024, 6:46am UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819/4 "2024-02-04T06:46:46Z")

</div>

What you want is a [diagnostic fix-it](https://github.com/apple/swift/blob/2fa1022a912a1c07db2a3596d494adb35a28b5f3/docs/Diagnostics.md#fix-its), which is actually done in the language. It would be best if made an issue on the GitHub repo.

To give a bit more on the syntax, what you are referring to are [capture lists](https://www.hackingwithswift.com/articles/179/capture-lists-in-swift-whats-the-difference-between-weak-strong-and-unowned-references). Annoyingly to me, it isn't defined in the documentation for syntax structure but only in the documentation for [ARC](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/automaticreferencecounting/#Defining-a-Capture-List).

---

<div class="post-metadata">

**Author:** ![richoncode](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/richoncode/32/33891_2.png) [@richoncode](https://forums.swift.org/u/richoncode)\
**Post date:** [February 8, 2024, 3:33am UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819/5 "2024-02-08T03:33:38Z")

</div>

I’ll take a look and put that in.  
Thank you.
