www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1908] New: Various closure problems

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: dvdfrdmn 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;


-- 
Mar 11 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908





------- Comment #1 from dvdfrdmn users.sf.net  2008-03-11 19:25 -------
Created an attachment (id=234)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=234&action=view)
Test case closure5w


-- 
Mar 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908





------- Comment #2 from dvdfrdmn users.sf.net  2008-03-11 19:26 -------
Created an attachment (id=235)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=235&action=view)
Test case closure8w


-- 
Mar 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908





------- Comment #3 from dvdfrdmn users.sf.net  2008-03-11 19:27 -------
Created an attachment (id=236)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=236&action=view)
Test case closure11w


-- 
Mar 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908





------- Comment #4 from dvdfrdmn users.sf.net  2008-03-11 19:28 -------
Created an attachment (id=237)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=237&action=view)
Test case closure13w


-- 
Mar 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908





------- Comment #5 from dvdfrdmn users.sf.net  2008-03-11 19:41 -------
Created an attachment (id=238)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=238&action=view)
Test case closure14

Similar to closure13w, but causes an ICE.  Also affects DMD 1.x.


-- 
Mar 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908





------- Comment #6 from bugzilla digitalmars.com  2008-04-24 04:44 -------
Patches for 11w and 13w were folded in to DMD 2.013. 13w was folded in to DMD
1.029, fixing 14.

5w and 8w are left.


-- 
Apr 24 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1908


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #7 from Don <clugdbug yahoo.com.au> 2010-10-19 23:55:58 PDT ---
Test case 8w is a duplicate of bug 3326, and isn't actually a closure bug. 
Test case 5w is a duplicate of bug 1841. I'm therefore closing this bug, as the
other cases have been fixed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 19 2010