Thread overview
[Issue 22128] opApply delegate can escape scope without duly invoking GC allocation
Feb 21, 2022
Walter Bright
Feb 21, 2022
Walter Bright
Feb 21, 2022
Walter Bright
Feb 21, 2022
Eyal
February 21, 2022
https://issues.dlang.org/show_bug.cgi?id=22128

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |bugzilla@digitalmars.com

--
February 21, 2022
https://issues.dlang.org/show_bug.cgi?id=22128

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
If `scope` is added just before `int delegate`, the `_dlg = dlg;` will be diagnosed as an error.

--
February 21, 2022
https://issues.dlang.org/show_bug.cgi?id=22128

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
The problem is solved if -preview=dip1000 is used to compile it.

But as a general practice, I recommend adding `scope` to the delegate parameter
to opApply().

--
February 21, 2022
https://issues.dlang.org/show_bug.cgi?id=22128

--- Comment #3 from Eyal <eyal@weka.io> ---
When is dip1000 becoming default? Until then - the default behavior is buggy.

Is the bug policy to reject any bug that will be solved by future features in preview mode?

--