Swift 2b2: Backticks around keywords are ignored in closures with implicit arguments and returns
| Originator: | rix.rob | ||
| Number: | rdar://21558949 | Date Originated: | 25-Jun-2015 10:39 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A121l) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Backticks to enable the use of keywords as ordinary symbols don’t work in closures with implicit arguments and returns.
Steps to Reproduce:
1. Compile this:
struct S {}
func `if`(S) -> S { return S() }
func g(S -> S) {}
func h() {
g { `if`($0) }
}
Expected Results:
Compilation.
Actual Results:
Errors:
boom.swift:5:9: error: expected expression, var, or let in 'if' condition
g { `if`($0) }
^
boom.swift:5:2: error: cannot invoke 'g' with an argument list of type '(() -> _)'
g { `if`($0) }
^
boom.swift:5:4: note: expected an argument list of type '(S -> S)'
g { `if`($0) }
^
Regression:
This doesn’t happen if:
1. you add a `return` keyword to the closure.
2. you use a first-order value instead of a closure, i.e. f(`if`(S())) where f : S -> ().
3. you use a named parameter.
4. you pass `if` directly as a referent instead of closing over it, i.e. f(`if`) where f : (S -> S) -> ().
5. you get fed up and name the function something else instead. Haha, as if that would ever happen!
Notes:
N/A
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!