Xcode-7 (7A120f): «Hidden» variable name on exhaustive `catch` block

Originator:me
Number:rdar://21396321 Date Originated:15-Jun-2015 09:14 PM
Status:Closed Resolved:
Product:Developer Tools Product Version:Xcode-7 (7A120f)
Classification:Serious Bug Reproducible:Always
 
Summary:
When writing a `do`/`catch` block with an exhaustive `catch` `Swift` is adding a hidden `let` called `error` that limits the definition of a variable with that name outside of the calling block.

Steps to Reproduce:
Copy the following code to a `Playground`:

```
enum TestError: ErrorType {
  case HiddenErrorVariable
}

func throwingFunction() throws -> () {
  throw TestError.HiddenErrorVariable
}

let error: TestError
do {
  try throwingFunction()
} catch {
  error = TestError.HiddenErrorVariable
  
  print(error)
}

print(error)
```

Expected Results:
Inside the `catch` block I should be able to assign to my own `error` variable because is an exhaustive `catch`.

Actual Results:
`Swift` «hijacks» the `error` variable inside the exhaustive `catch` instead of using a `_` as a `hidden` variable name.

Regression:
None.

Notes:
`Swift` shouldn’t be naming `hidden` variables and instead should use of the `_` character when «needing» to have some «unused» parameter.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!