Bug 24096 – a pure function is in fact impure for local automatic external variables

Status
NEW
Severity
trivial
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2023-08-22T00:51:37Z
Last change time
2024-12-13T19:30:28Z
Assigned to
No Owner
Creator
andreiD
Moved to GitHub: dmd#18183 →

Comments

Comment #0 by andreiD — 2023-08-22T00:51:37Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18183 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB