Bug 6293 – [Regression 2.054] The expression x.y makes the function impure when the 'x' part is not just a variable
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-07-12T01:38:00Z
Last change time
2011-08-01T21:45:02Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
kennytm
Comments
Comment #0 by kennytm — 2011-07-12T01:38:45Z
Test case
-----------------------
class C6293 {
int token;
}
struct S6293 {
const(C6293)[] tokens;
void f() const pure {
const(C6293) a = tokens[0];
int b = a.token; // <-- separating it is ok.
int c = tokens[0].token; // <-- cannot access mutable data 'token'
}
}
-----------------------
x.d(9): Error: pure nested function 'f' cannot access mutable data 'token'
-----------------------
If that 'b' can be accessed in a 'pure' function, there's no reason 'c' cannot.
*** Issue 6284 has been marked as a duplicate of this issue. ***
Comment #3 by kennytm — 2011-07-16T01:07:42Z
Further failing cases:
* f(x).member
* (*__withSym).member (which is what bug 6284 is about)
* ...
In a DotVarExp, whenever the 'e1' is not a VarExp or a DotVarExp, the purity check will fail even if 'e1' is already verified as pure.