On Sunday, 30 May 2021 at 09:39:28 UTC, cc wrote:

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
```

`@nogc`. Or check the output of `dmd -vgc` if you want something less strict.

Reply via email to