[Issue 21745] Closure created in struct constructor passed to class constructor is not heap allocated

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 22 13:20:19 UTC 2021


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #2 from RazvanN <razvan.nitu1305 at gmail.com> ---
As a workaround, simply returning `i` in the delegate seems to work correctly:

struct Foo
{
    int i;
    Bar bar;
    this(int i)
    {
        this.i = i;
        this.bar = new Bar({ return i; });
    }
}

--


More information about the Digitalmars-d-bugs mailing list