On Thursday, 27 May 2021 at 20:46:22 UTC, Adam D. Ruppe wrote:
On Thursday, 27 May 2021 at 20:44:21 UTC, frame wrote:
Did you mean to add the delegate as GC root or the data?

The delegate.ptr property.

Is there any way to enforce at compile time that we're not accidentally allocating when creating a delegate, other than being carefully aware of what variables are referenced inside the body? Something like:
```d
auto dg = delegate {...}
assert(dg.ptr is null, "Oops, we unintentionally allocated on GC here, check delegate body!"); // can't static assert
```

Reply via email to