Bug 7608 – __traits(allMembers) is broken

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-29T03:08:00Z
Last change time
2012-03-27T17:03:23Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-02-29T03:08:58Z
import std.stdio; struct Base(bool T) { static if (T) { int x; } int y; } void main() { alias Base!false Type; auto fields = [__traits(allMembers, Type)]; writeln(fields); // writes ["x", "y"] } "x" does not exist in the Base!false instance.
Comment #1 by andrej.mitrovich — 2012-02-29T03:12:24Z
Actually
Comment #2 by andrej.mitrovich — 2012-02-29T03:13:06Z
Actually it's broken for non-template types too: import std.stdio; import std.traits; struct Base { version(none) { int x; } int y; } void main() { auto vals = [__traits(allMembers, Base)]; writeln(vals); // writes ["x", "y"] }
Comment #3 by k.hara.pg — 2012-03-24T01:36:38Z
Comment #4 by github-bugzilla — 2012-03-27T14:32:13Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ebd56ebac678ddd526a5ccad1787fbfa31530aaa Merge pull request #832 from 9rnsr/fix7608 Issue 7608 - __traits(allMembers) is broken