[Issue 1908] New: Various closure problems
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 11 17:23:38 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1908
Summary: Various closure problems
Product: D
Version: 2.012
Platform: All
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: dvdfrdmn at users.sf.net
Attached closure-related test cases fail.
closure5w.d: Segfaults. Only f() creates a closure and 'dg = & i' does not get
a
valid reference to it.
closure8w.d: Fails with ArrayBoundsError.
closure11w.d: Assert fails. The tests in Function::needsClosure only
check f->isVirtual(), but a virtual function can call a non-virtual
function which does non-local access. I fixed this in GDC by
testing f->isThis() instead.
closure13w.d: Assert fails. DotVarExp::semantic does not call
checkNestedReference for the 'this' of an outer function.
I fixed this in GDC by adding a semantic() call:
// Skip over nested functions, and get the enclosing
// class type.
Dsymbol *s = tcd->toParent();
while (s && s->isFuncDeclaration())
{ FuncDeclaration *f = s->isFuncDeclaration();
if (f->vthis)
{
e1 = new VarExp(loc, f->vthis);
}
s = s->toParent();
}
if (s && s->isClassDeclaration())
e1->type = s->isClassDeclaration()->type;
+ e1 = e1->semantic(sc); // Added to get corrected nested refs
goto L1;
--
More information about the Digitalmars-d-bugs
mailing list