> On Oct 9, 2016, at 5:07 PM, Jean-Denis Muys via swift-users > <swift-users@swift.org> wrote: > > Here is a contrived reduction of my problem > > func mainFunction(closure:(Int) -> Int) -> Int { > > func closureDoubled(_ n: Int) -> Int { > let result = closure(n) > return 2*result > } > > let temp1 = closure(1) > let temp2 = closureDoubled(1) > return temp1+temp2 > } > > The line "let result = closure(n)" is refused by the compiler with the error > message "declaration over non closing parameter may allow it to escape". > > First off, while I know what an escaping or a non-escaping closure is, I find > this error message utterly impossible to understand. To begin with, the > sentence "non closing parameter" is meaningless to me. > > In any case, my main function is passed a non-escaping closure. I want to > call it from inside it, the compiler is ok with. I want also to call it from > a nested function, but the compiler disagrees. > > I believe the compiler should not complain here. Did I miss anything?
I agrre that the compiler should be able to determine that the closure is nonescaping in this case, and that that diagnostic is in dire need of revision. Would you be able to file a couple of bug reports, one to allow this example, and one to improve the error message? -Joe
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users