apple / swift-argument-parser

Straightforward, type-safe argument parsing for Swift
Apache License 2.0
3.3k stars 311 forks source link

Ambiguous use of 'init(name:parsing:help:completion:transform:)' when transform throws #618

Closed Coeur closed 5 months ago

Coeur commented 6 months ago

Ambiguous use of 'init(name:parsing:help:completion:transform:)' when transform throws.

This is a regression introduced with #477 (swift-argument-parser 1.2.0).

ArgumentParser version: main branch Swift version: swiftlang-5.11

Checklist

Steps to Reproduce

public struct MyError: Error {}

struct MyCommand: ParsableCommand {
    @Option(transform: {
        guard let url = URL(string: $0) else {
            throw MyError()
        }
        return url
    })
    var test: URL?
}

Expected behavior

No errors.

Actual behavior

Ambiguous use of 'init(name:parsing:help:completion:transform:)'

Workarounds: