Skip to content

Commit

Permalink
Fix for @Option(transform:) with optional type (#619)
Browse files Browse the repository at this point in the history
Due to the restructuring in #477, there was ambiguity between the
unconstrained `@Option` initializer that uses a transform (but no
initial value) and the one that is constrained to the property being
optional. This marks the unconstrained version as disfavored, which
allows overload resolution to select the optional version when
appropriate.

Also fixes this for `@Argument` and improves documentation
consistency for `@Option`.

Fixes #618.
  • Loading branch information
natecook1000 committed Mar 5, 2024
1 parent 1c8215f commit 7191549
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 98 deletions.
Expand Up @@ -2,15 +2,15 @@

## Topics

### Single Options
### Single-Value Options

- ``init(name:parsing:help:completion:)-7slrf``
- ``init(name:parsing:help:completion:)-4yske``
- ``init(name:parsing:help:completion:)-7slrf``
- ``init(wrappedValue:name:parsing:help:completion:)-7ilku``
- ``init(name:parsing:help:completion:transform:)-2wf44``
- ``init(name:parsing:help:completion:transform:)-25g7b``
- ``init(wrappedValue:name:parsing:help:completion:transform:)-2llve``
- ``SingleValueParsingStrategy``
- ``init(wrappedValue:name:parsing:help:completion:)-7ilku``

### Array Options

Expand Down
1 change: 1 addition & 0 deletions Sources/ArgumentParser/Parsable Properties/Argument.swift
Expand Up @@ -414,6 +414,7 @@ extension Argument {
/// - transform: A closure that converts a string into this property's
/// element type or throws an error.
@preconcurrency
@_disfavoredOverload
public init(
help: ArgumentHelp? = nil,
completion: CompletionKind? = nil,
Expand Down

0 comments on commit 7191549

Please sign in to comment.