Swift inconsistent warning: Result of call to 'xxx' is unused, where xxx is a function returning Void

I have the following abstract class:

class CachedObject: Decodable, Identifiable, Equatable, Hashable {
    
    ...
    static func cached(id: Int) -> Self? {
        // Returns an object from a cache
    }

    // Load object from the server
    static func fetch(id: Int, detail: Int=1, handler: @escaping ((Self?) -> Void)) {
        guard id > 0 else {
            handler(nil)
            return
        }
        if let object = cached(id: id) {
            // The object is in the cache
            if object.detail < detail {
                // Reload the object
                object.reload(detail: detail, handler: handler)
                return
            }
            handler(object as? Self)
            return
        }
        // Do something
    }
    
    // Reload existing object
    func reload(detail: Int=1, handler: @escaping ((Self?) -> Void)) {
        // Do something
    }
}

It gives the following warning on the call of object.reload(): Result of call to 'reload(detail:handler:)' is unused But this function returns Void.

If I force it with @discardableResult, I get the following warning: @discardableResult declared on a function returning Void is unnecessary And the previous warning is still here.

I used to silence this warning with: _ = object.reload(detail: detail, handler: handler) But since Swift 5, if I do that, the compiler fails with nonzero exit code, with the following logs:

11. While type-checking expression at [/Users/xxx/Xcode/xxx/Shared/Model/CachedObject.swift:71:17 - line:71:67] RangeText="_ = object.reload(detail: detail, handler: handler" 12. While type-checking-target starting at /Users/xxx/Xcode/xxx/Shared/Model/CachedObject.swift:71:17 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it):

Anyone having this issue when using _ = since Swift 5? Note that I also have the same compiler error somewhere else, where I use { _ in } as an argument to a function (I should make another report).

And why does Swift consider that my function reload returns a value and gives me this warning, in the first place?

Is it only a warning (in this case you should ignore) or a crash as well ?

In some cases compiler issues undue warnings…

Just an idea, in case: could you try and move func reload to the beginning of the class ?

Swift inconsistent warning: Result of call to 'xxx' is unused, where xxx is a function returning Void
 
 
Q