[Issue 6230] New: Member functions can no longer be weakly pure
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 30 08:44:34 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6230
Summary: Member functions can no longer be weakly pure
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: blocker
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: kennytm at gmail.com
--- Comment #0 from kennytm at gmail.com 2011-06-30 08:39:36 PDT ---
(See http://lists.puremagic.com/pipermail/phobos/2011-June/005487.html and
comments in Phobos commit 4f28d** for existing discussion.)
After DMD commit 84b4f* a member function can no longer be pure, claiming
itself as a nested function. I believe this is a bug because the relevant DMD
code
Dsymbol *vparent = v->toParent2();
for (Dsymbol *s = sc->func; s; s = s->toParent2())
{
if (s == vparent)
break;
FuncDeclaration *ff = s->isFuncDeclaration();
if (!ff)
break;
if (ff->setImpure())
{ error("pure nested function '%s' cannot access mutable data
'%s'",
ff->toChars(), v->toChars());
break;
}
}
cannot check the case when 'vparent' is an aggregrate. Nevertheless, this leads
to commits d014a and 40def in druntime, and 4f28d in Phobos**, which probably
means this bug is INVALID.
Test case:
-----------------------
struct S {
int p;
int q() const pure { // <-- Error
return p;
}
}
class C {
int p;
int q() const pure { // <-- Error
return p;
}
}
int q2(ref const S s) pure { // <-- Currently OK
return s.p;
}
int q3(ref const C c) pure { // <-- Currently OK
return c.p;
}
-----------------------
y.d(4): Error: pure nested function 'q' cannot access mutable data 'p'
y.d(11): Error: pure nested function 'q' cannot access mutable data 'p'
-----------------------
* https://github.com/D-Programming-Language/dmd/commit/84b4f
** https://github.com/D-Programming-Language/druntime/commit/d014a
https://github.com/D-Programming-Language/druntime/commit/40def
https://github.com/D-Programming-Language/phobos/commit/4f28d
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list