[Issue 3316] Functions nested in a pure templated function cannot reference its local variables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 29 23:56:57 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3316
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2009-09-29 23:56:55 PDT ---
This is happening because the nested template is being marked as pure. This
happens in mtype.c, in TypeFunction::semantic, line 4038:
the template function gets marked as pure/nothrow because it's taken from the
parent scope. This is wrong, because pure/nothrow shouldn't be inherited by
members.
PATCH: In DeclarationExp::semantic(Scope *sc), pure (and nothrow) should not be
passed on to members. Turn it off while running semantic on those functions.
Index: expression.c
===================================================================
--- expression.c (revision 196)
+++ expression.c (working copy)
\@@ -4505,8 +4505,12 @@
}
if (!s->isVarDeclaration())
{
+ // 'pure nothrow' is not inherited by member declarations
+ int scopePureNothrow = sc->stc & (STCpure | STCnothrow);
+ sc->stc ^= scopePureNothrow;
declaration->semantic(sc);
s->parent = sc->parent;
+ sc->stc ^= scopePureNothrow;
}
if (!global.errors)
{
--
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