# Custom Bool operator warning issue

**URL:** <https://forums.swift.org/t/custom-bool-operator-warning-issue/55002>\
**Category:** Using Swift\
**Tags:** operators\
**Created:** [February 1, 2022, 1:39am UTC](https://forums.swift.org/t/custom-bool-operator-warning-issue/55002 "2022-02-01T01:39:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [February 1, 2022, 1:39am UTC](https://forums.swift.org/t/custom-bool-operator-warning-issue/55002/1 "2022-02-01T01:39:53Z")

</div>

To experiment with keeping my app "explanation mark free" I've created my own analogues for `!=` and `!` operators some time ago (don't want to go into further details on this, ask me privately if you want to know what "explanation mark free" gives).

```
infix operator <> : ComparisonPrecedence

extension Equatable {
    static func <> (a: Self, b: Self) -> Bool {
        a == b ? false : true
    }
}

extension Optional {
    static func <> (a: Wrapped?, b: _OptionalNilComparisonType) -> Bool {
        a == b ? false : true
    }

    static func <> (a: _OptionalNilComparisonType, b: Wrapped?) -> Bool {
        a == b ? false : true
    }
}

extension Bool {
    var not: Bool {
        self == false
    }
}

```

This generally works very well. However I noticed some significant drawback in that I am not getting important warnings (I wish there was a way to force them to be errors instead):

```
func bar() {
    let x = 0
    
    if x != nil { // Warning: Comparing non-optional value of type 'Int' to 'nil' always returns true
        print("hello")
    }
    if x != 0 {
        print("hello") // Warning: Will never be executed
    }
    
    if !(x == 0) {
        print("hello") // Warning: Will never be executed
    }
    
    if x <> nil { // no warning
        print("hello")
    }
    if x <> 0 {
        print("hello") // no warning
    }
    if (x == 0).not {
        print("hello") // no warning
    }
}

```

Is there a way to get those warnings for my custom operators / functions?
