void main()
{
int a;
//a pure function is in fact impure for local automatic external variables
pure void f(){int x = a;} // compile
pure void g(){int x; a = x;} // compile
}
Comment #1 by destructionator — 2023-08-22T01:06:02Z
I don't understand, what is the bug supposed to be here?
D's pure functions are allowed to use references passed to them, which includes the local variables for nested functions.
Comment #2 by andreiD — 2023-08-22T01:13:10Z
if you ban it, the degegates will fall off?
Comment #3 by andreiD — 2023-08-22T01:21:34Z
(In reply to andreiD from comment #2)
> if you ban it, the delegates will fall off?
Comment #4 by andreiD — 2023-08-22T01:43:47Z
Shouldn't in the delegate, we capture the variable of the function itself where the delegate is called, and not an external variable outside the function!
Comment #5 by robert.schadek — 2024-12-13T19:30:28Z