[Issue 17718] [scope] function literal arguments can be escaped

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Sep 9 04:48:47 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17718

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla at digitalmars.com
         Resolution|---                         |INVALID

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
What's happening here is that the function literal f is getting its attributes
inferred, so 'return scope' is inferred. The explicit function f is not getting
its attributes inferred, the parameter is 'scope', not 'return scope', and so
it errors.

If the latter is changed to:

    auto f(scope S s) { return s.leak; }

then no error occurs, because attribute inference is done for auto functions.

The compiler is working correctly.

--


More information about the Digitalmars-d-bugs mailing list