Local functions cannot reference themselves
| Originator: | info | ||
| Number: | rdar://19861074 | Date Originated: | 17-Feb-2015 09:48 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | 1.1 |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
Local functions cannot be made recursive.
Steps to Reproduce:
func a() {
func f(a: Bool) {
if a {
f(false)
}
}
}
Expected Results:
Code compiles.
Actual Results:
Error: “Local functions cannot reference themselves”.
Regression:
Member or global functions can be recursive.
Notes:
My temporary work around is to define f as an implicitly unwrapped optional:
var f: (() -> ())!
f = {
….
f()
….
}
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!