Thread overview
[Issue 1418] New: tupleof bug on nested classes
Aug 13, 2007
d-bugmail
Jul 28, 2010
Don
Aug 06, 2010
Walter Bright
August 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1418

           Summary: tupleof bug on nested classes
           Product: D
           Version: 1.020
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: yanikibo@gmail.com


.tupleof accesses an extra (unknown) member on nested classes.
The following example shows this bug on dmd 1.020 and 2.003, also gdc gives a
similar result

--- main.d ---

import std.stdio;

class A
{
    char name = 'A';
    class B
    {
        char name = 'B';
    }
}

void main()
{
    class C
    {
        char name = 'C';
    }

    A a = new A;
    a.B b = a.new B;
    C c = new C;

    writefln(a.tupleof); // prints: A
    writefln(b.tupleof); // prints: B main.A
    writefln(c.tupleof); // prints: C 0000
}


-- 

August 13, 2007
<d-bugmail@puremagic.com> wrote in message news:bug-1418-3@http.d.puremagic.com/issues/...
> http://d.puremagic.com/issues/show_bug.cgi?id=1418
> .tupleof accesses an extra (unknown) member on nested classes.
> The following example shows this bug on dmd 1.020 and 2.003, also gdc
> gives a
> similar result

It's 'this.outer'.  I'm surprised that it shows up in the tupleof, though.


July 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1418


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-07-28 13:15:06 PDT ---
tupleof shouldn't be including hidden 'this' members.

PATCH: mtype.c, line 7138, TypeClass::dotExp()

    if (ident == Id::tupleof)
    {
        /* Create a TupleExp
         */
        e = e->semantic(sc);    // do this before turning on noaccesscheck
        Expressions *exps = new Expressions;
        exps->reserve(sym->fields.dim);
        for (size_t i = 0; i < sym->fields.dim; i++)
        {   VarDeclaration *v = (VarDeclaration *)sym->fields.data[i];
+            // Don't include hidden 'this' pointer
+            if (v->isThisDeclaration())
+                continue;
            Expression *fe = new DotVarExp(e->loc, e, v);
            exps->push(fe);
        }
        e = new TupleExp(e->loc, exps);
        sc = sc->push();
        sc->noaccesscheck = 1;
        e = e->semantic(sc);
        sc->pop();
        return e;
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1418


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2010-08-05 23:39:40 PDT ---
http://www.dsource.org/projects/dmd/changeset/604

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