Bug 19963 – [Regression 2.066 - 2.067.1] nested pure functions variable access

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-06-14T10:46:17Z
Last change time
2024-12-13T19:03:58Z
Assigned to
No Owner
Creator
Nicholas Wilson
Moved to GitHub: dmd#19584 →

Comments

Comment #0 by iamthewilsonator — 2019-06-14T10:46:17Z
From the source code of DMD no less! void f() { int fx; pure void g() { int gx; /+pure+/ void h() { int hx; /+pure+/ void i() { fx = 0; } } } } should give Error: pure nested function 'g' cannot access mutable data 'fx' if the commented out `purees are removed it should give Error: pure nested function 'i' cannot access mutable data 'fx' three times.
Comment #1 by iamthewilsonator — 2019-06-14T11:28:43Z
*** Issue 19964 has been marked as a duplicate of this issue. ***
Comment #2 by bugzilla — 2019-12-18T10:44:28Z
I'm not sure what the problem is?
Comment #3 by razvan.nitu1305 — 2020-02-13T11:01:26Z
The problem is that function g is pure, but it contains function i that accesses the variable fx which is outside of its scope, thus violating purity. This code should issue an error, but it doesn't.
Comment #4 by robert.schadek — 2024-12-13T19:03:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19584 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB