Skip to content

Commit 67decfc

Browse files
committed
Fix #72841 Bug
swiftlang/swift#72841 (cherry picked from commit 2634117)
1 parent 4f680a7 commit 67decfc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/ArgumentParser/Parsing/CommandParser.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ struct AutodetectedGenerateCompletions: ParsableCommand {
345345
@Flag() var generateCompletionScript = false
346346
}
347347

348+
func swiftBug72841Unwrap<T>(_ x: T) -> T { x }
349+
func swiftBug72841Unwrap<T>(_ x: T?) -> T { x! }
350+
348351
extension CommandParser {
349352
func checkForCompletionScriptRequest(_ split: inout SplitArguments) throws {
350353
// Pseudo-commands don't support `--generate-completion-script` flag
@@ -363,14 +366,14 @@ extension CommandParser {
363366
throw CommandError(
364367
commandStack: commandStack,
365368
parserError: .completionScriptRequested(
366-
shell: result.generateCompletionScript))
369+
shell: swiftBug72841Unwrap(result).generateCompletionScript))
367370
}
368371

369372
// Check for for `--generate-completion-script` without a value
370373
var autodetectedParser = CommandParser(AutodetectedGenerateCompletions.self)
371374
if let result = try? autodetectedParser.parseCurrent(&split)
372375
as? AutodetectedGenerateCompletions,
373-
result.generateCompletionScript
376+
swiftBug72841Unwrap(result).generateCompletionScript
374377
{
375378
throw CommandError(
376379
commandStack: commandStack,

0 commit comments

Comments
 (0)