# Lldb: Unable to bind generic parameters in context with weakly captured self

**URL:** <https://forums.swift.org/t/lldb-unable-to-bind-generic-parameters-in-context-with-weakly-captured-self/74236>\
**Category:** LLDB\
**Tags:** generics, bug, lldb\
**Created:** [August 29, 2024, 2:35pm UTC](https://forums.swift.org/t/lldb-unable-to-bind-generic-parameters-in-context-with-weakly-captured-self/74236 "2024-08-29T14:35:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuchlej](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stuchlej/32/7751_2.png) [@stuchlej](https://forums.swift.org/u/stuchlej)\
**Post date:** [August 29, 2024, 2:35pm UTC](https://forums.swift.org/t/lldb-unable-to-bind-generic-parameters-in-context-with-weakly-captured-self/74236/1 "2024-08-29T14:35:11Z")

</div>

Hello,

I have opened an issue regarding LLDB, see [lldb: Unable to bind generic parameters in context with weakly captured self · Issue #9194 · swiftlang/llvm-project · GitHub](https://github.com/swiftlang/llvm-project/issues/9194) .

TL;DR:  
If you capture weakly a generic class, lldb is not able to bind generic variables, for example:

```swift
final class Bridge<T> {
    var current: T
    init(c: T) { current = c }
    func foo() {
        Task { [weak self] in
            print(self?.current) // HERE!
        }
    } 
}

```

Do you happen to know about any workaround, or whether the issue was already fixed? I have tested the issue on Xcode 15.4.

---

<div class="post-metadata">

**Author:** ![augusto2112](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/augusto2112/32/10731_2.png) [@augusto2112](https://forums.swift.org/u/augusto2112)\
**Post date:** [August 29, 2024, 4:36pm UTC](https://forums.swift.org/t/lldb-unable-to-bind-generic-parameters-in-context-with-weakly-captured-self/74236/2 "2024-08-29T16:36:41Z")

</div>

Hi Mikoláš,

Thanks for opening the issue! This seems to be fixed in OSS LLDB:

```swift
(lldb) expr T.self
(Int.Type) $R4 = Int
(lldb) expr self
(q.Bridge<Int>?) $R5 = 0x000060000018c080 {
  current = 1
}

```

You can use `p` or, if that doesn't work, `v`, to print on older LLDBs (in general I default to `p` over `expr`, as that is usually more efficient).

```swift
// On older lldb
(lldb) expr self
error: <EXPR>:2:43: error: cannot find type '$__lldb_context' in scope
extension Swift.Optional where Wrapped == $__lldb_context {
                                          ^ ~~~~~~~~~~~~~~

error: <EXPR>:19:27: error: instance method '$__lldb_user_expr_1' requires the types 'Bridge<Int>' and '<<error type>>' be equivalent
    $ __lldb_injected_self.$__ lldb_user_expr_1(
                          ^

<EXPR>:4:17: note: where 'Wrapped' = 'Bridge<Int>'
  mutating func $__lldb_user_expr_1(_ $__lldb_arg : UnsafeMutablePointer<Any>) {
                ^

(lldb) p self
(q.Bridge<Int>?) 0x0000600001750140 {
  current = 1
}

```
