Skip to content

unneeded_escaping false positive in 0.63.0 #6410

@Nef10

Description

@Nef10

New Issue Checklist

Bug Description

(fairly) minimal example I created:

import Foundation

public class Uploader {

    public func start(completion: @escaping (Result<String, Error>) -> Void) {
        DispatchQueue.global(qos: .userInitiated).async {
            let result: [Result<String, Error>] = [1].map { _ in .success("Success") }
            completion(result.first!)
        }
    }
}

Running:

swiftlint lint --only-rule unneeded_escaping --no-cache ./a.swift

Results in:

a.swift:5:35: warning: Unneeded Escaping Violation: @escaping attribute not required as 'completion' does not escape (unneeded_escaping)

but it cannot be removed:

swift ./a.swift                                                  
a.swift:6:57: error: escaping closure captures non-escaping parameter 'completion'

It somehow has todo with the map, because if I change the code to let result = Result.success("Success"), no error is reported anymore

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions