# Sendability checking for global variables

**URL:** <https://forums.swift.org/t/sendability-checking-for-global-variables/56515>\
**Category:** Using Swift\
**Created:** [April 4, 2022, 4:49pm UTC](https://forums.swift.org/t/sendability-checking-for-global-variables/56515 "2022-04-04T16:49:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MuniekMg](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/muniekmg/32/22206_2.png) [@MuniekMg](https://forums.swift.org/u/MuniekMg)\
**Post date:** [April 4, 2022, 4:49pm UTC](https://forums.swift.org/t/sendability-checking-for-global-variables/56515/1 "2022-04-04T16:49:07Z")

</div>

Hi, I was experimenting with Sendable using Swift Development Snapshot 2022-03-22 and -enable-actor-data-race-checks flag.

Does Swift check sendability for global variables? see an example:

```swift
// Non-Sendable
class MyClass {
    var value: Int = 0
}

// Global
let otherClass = OtherClass()

class OtherClass {
    var myClassOutside: MyClass!
}

actor MyActor {
    // Non-Sendable actor-isolated instance of MyClass
    var myClass: MyClass = .init()
    
    func doSomethingInside() {
        // Save reference to non-Sendable actor-isolated myClass in global otherClass
        // No warnings about MyClass being Non-Sendable
        // but I think it is ok, there is no problem until we use it outside this actor concurrency domain?
        otherClass.myClassOutside = myClass
        
        Task.detached {
            // mutating MyClass concurrently in Task.detached
            // No warnings about MyClass being Non-Sendable
            otherClass.myClassOutside.value = 6
        }
    }
}

```

Task.detached does not capture otherClass because it is global and because of that slips through sendability checking?

Thanks :)
