[swift-dev] Help needed: SE-0035 design detail

Daniel Duan daniel at duan.org
Sun Apr 10 14:46:56 CDT 2016

Hi all,

I'm in the process of implementing SE-0035, which limits capturing inout
parameter to @noescape contexts. The proposal is clear on capture behavior for
the following:

1. closure literals
2. nested function passed as arguments.

But I'm not sure what to do with this case, in which 'x' escapes.

func captureAndEscape(inout x: Int) -> () -> Void { func foo()
{ _ = x } return foo }

The most obvious answer is it should be considered with the same rule as
a closure literal, but a nested function can not have @noescape in its type
(for now anyways).

So, should this be legal, then? If not, where/how should the error be? 

More information about the swift-dev mailing list