Bug 18835 – [REG 2.064] to!string doesnt work on enum member starting with two underscores

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-06T18:18:26Z
Last change time
2018-05-06T18:41:55Z
Assigned to
No Owner
Creator
Basile-z

Comments

Comment #0 by b2.temp — 2018-05-06T18:18:26Z
test case: void main() { import std.conv : to; enum A{_a, __a} assert(to!string(cast(A) 0) == "_a"); // OK assert(to!string(cast(A) 1) == "__a"); // fails }
Comment #1 by b2.temp — 2018-05-06T18:34:35Z
It's because __traits(allMembers) seems to ignore members starting with double underscores. It's used in the std.format.formatValueImpl overload specialized for enums.
Comment #2 by b2.temp — 2018-05-06T18:41:55Z
Such identifiers are reserved so i suppose that allMembers filters them out on purpose.