Aller au contenu

Completion Not Called On Every Path (ARCH9020)

Ce contenu n’est pas encore disponible dans votre langue.

Key swift.async.completion-not-called-on-every-path · Severity warning · Category async

Flags a completion-handler function with an early return that never calls the completion - the caller waits forever.

func load(completion: @escaping (Result<User, Error>) -> Void) {
guard let url = url else { return }
...
}
guard let url = url else { completion(.failure(AppError.badUrl)); return }

Call the completion on every exit path, or convert the function to async.