Comment #0 by dlang-bugzilla — 2014-12-25T22:16:16Z
From the spec:
> The .tupleof property returns an ExpressionTuple of all the fields in the class, excluding the hidden fields and the fields in the base class.
However, .tupleof seems to include non-static structs' hidden field:
///////////////// test.d ////////////////
void fun()
{
struct S
{
int i;
void m() { }
}
S s;
static assert(s.tupleof.length == 1);
}
/////////////////////////////////////////
This also seems to affect writeln: `writeln(s)` will print "S(0, null)".
Comment #1 by k.hara.pg — 2014-12-28T07:24:02Z
> > The .tupleof property returns an ExpressionTuple of all the fields in the class, excluding the hidden fields and the fields in the base class.
The spec is in the section "Class Properties", so in the strict sense, it would not affect the semantics of struct tupleof property.
From the view of implementation side, the inconsistency was introduced by fixing issue 1418. By the fix class tupleof was changed not listing hidden field but struct tupleof was not changed.
From the user side, S.tupleof[$-1] is sometimes used to actually handle the hidden context pointer.
Therefore, modifying tupleof behavior may affect not small code.
Comment #2 by robert.schadek — 2024-12-13T18:38:36Z