www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1418] New: tupleof bug on nested classes

reply d-bugmail puremagic.com writes:
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
}


-- 
Aug 13 2007
next sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
<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.
Aug 13 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1418


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Jul 28 2010
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Aug 05 2010