Comment #0 by destructionator — 2023-01-15T01:35:36Z
This assert should NOT pass:
```
struct W {
string delegate() magic;
void content(lazy string s) {
magic = &s;
}
string test;
}
void main() {
int onStack;
W w;
w.content = w.test;
auto diff = w.magic.ptr - cast(void*) &onStack;
if(diff < 0) diff = -diff;
assert(diff > 64);
}
```
Notice that if you change it to an explicit delegate:
void content(string delegate() s) {
// snip
w.content = () => w.test;
It will fail.
Can also confirm by using the disassembly to see the lack of _d_allocmemory for the closure.
The spec explicitly permits taking the address of a lazy param to get the delegate and it is not marked with any lifetime restrictions, so the implementation is wrong to give it limited lifetime.
Comment #1 by robert.schadek — 2024-12-13T19:26:38Z