.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 }
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; }
http://www.dsource.org/projects/dmd/changeset/604
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル