[Issue 17718] [scope] function literal arguments can be escaped
https://issues.dlang.org/show_bug.cgi?id=17718 Walter Brightchanged: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution|--- |INVALID --- Comment #3 from Walter Bright --- 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. --
[Issue 17718] [scope] function literal arguments can be escaped
https://issues.dlang.org/show_bug.cgi?id=17718 --- Comment #2 from ZombineDev--- (Where line 9 is the `alias f = ...` same as in the original example.) --
[Issue 17718] [scope] function literal arguments can be escaped
https://issues.dlang.org/show_bug.cgi?id=17718 --- Comment #1 from ZombineDev--- If I change the structure to: struct S { int p; int* leak() return scope { return } } I get: scope_bug17718.d(9): Error: returning s.leak() escapes a reference to parameter s, perhaps annotate with return Where exactly is one supposed to add return? --
[Issue 17718] [scope] function literal arguments can be escaped
https://issues.dlang.org/show_bug.cgi?id=17718 ZombineDevchanged: What|Removed |Added CC||petar.p.ki...@gmail.com --