Bug 13894 – tupleof does not exclude hidden members

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-25T22:16:16Z
Last change time
2024-12-13T18:38:36Z
Keywords
spec, wrong-code
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#17692 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17692 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB