kareman / SwiftShell

A Swift framework for shell scripting.
https://kareman.github.io/SwiftShell
MIT License
1.03k stars 87 forks source link

Tupling issue? #83

Closed scifiman closed 4 years ago

scifiman commented 4 years ago

Xcode 11.5 is generating a warning, though not an error, when trying to use a try catch block.

do { try myCommand.finish() } catch CommandError.returnedErrorCode(let error) { print("Error while trying to finish: \(error).") } catch { print("Caught unknown error.") }

On the line } catch CommandError.returnedErrorCode(let error) {, Xcode generates the warning "Cannot match several associated values at once, implicitly tupling the associated values and trying to match that instead". This line appears to be a direct copy of an example from the Reference API so I'm assuming this is a new warning with Xcode.

The project still builds successfully and I haven't observed any unexpected results but I also haven't generated any code that would trigger this purposefully.

kareman commented 4 years ago

Thank you, good catch. I have updated the README with the correct example code:

let someCommand = runAsync("cmd", "-n", 245)
// ...
do {
    try someCommand.finish()
} catch let CommandError.returnedErrorCode(command, errorcode) {
    print("Command '\(command)' finished with exit code \(errorcode).")
}