[Issue 4291] Pure functions cannot access mixed in variables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 7 02:41:28 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4291
Shin Fujishiro <rsinfu at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Shin Fujishiro <rsinfu at gmail.com> 2010-06-07 02:41:25 PDT ---
Patch against DMD r524:
====================
--- src/expression.c
+++ src/expression.c
@@ -4406,7 +4406,7 @@ Expression *VarExp::semantic(Scope *sc)
error("pure function '%s' cannot access mutable static data
'%s'",
sc->func->toChars(), v->toChars());
}
- else if (sc->func->isPure() && sc->parent != v->parent &&
+ else if (sc->func->isPure() && sc->parent->pastMixin() !=
v->parent->pastMixin() &&
!v->isImmutable() &&
!(v->storage_class & STCmanifest))
{
====================
The patched code also deals with function's scope (sc->parent->pastMixin) so
that this valid code is accepted:
--------------------
void test() pure
{
mixin declareVariable;
mixin declareFunction;
readVar();
}
template declareVariable() { int var; }
template declareFunction()
{
int readVar() { return var; }
}
--------------------
--
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