Bug 5192 – Pure function cannot access static __dollar
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-11-09T03:32:00Z
Last change time
2011-06-15T11:53:25Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bugzilla
Comments
Comment #0 by bugzilla — 2010-11-09T03:32:24Z
Test case:
void f() pure
{
static immutable int[3] a = [1,2,3];
auto i = a[$-1];
}
test.d(4): Error: pure function 'f' cannot access mutable static data '__dollar'
Comment #1 by bearophile_hugs — 2010-11-09T04:23:58Z
It compiles with DMD 2.050 if you remove "static":
void f() pure {
immutable int[3] a = [1,2,3];
auto i = a[$-1];
}
void main() {}