Bug 19854 – Code stops Compiling when removing pragma(msg, | probably related to UDAs on enums

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2019-05-08T15:45:06Z
Last change time
2024-12-13T19:03:18Z
Assigned to
No Owner
Creator
Felix Hufnagel
Moved to GitHub: dmd#17905 →

Comments

Comment #0 by puremagic — 2019-05-08T15:45:06Z
import std.stdio; import std.meta; import std.traits; import std.conv; struct UI_LABEL { string label; } enum isEnum(e) = is(e == enum); enum Type { @UI_LABEL("Hans") type_hans, @UI_LABEL("Peter") type_peter, } struct Node { Type type; } string generateUI(NODE)(NODE node) { string ret; static foreach(i, P; NODE.tupleof) {{ static if(isEnum!(typeof(P))) { ret ~= ", combo["; static foreach(o, O; EnumMembers!(typeof(P))) { ret ~= O.to!string; //********************************************** // ADD THIS LINE AND IT COMPILES JUST FINE //pragma(msg, __traits(getAttributes, EnumMembers!(typeof(P))[o])); //********************************************** static foreach(UDA; getUDAs!(EnumMembers!(typeof(P))[o], UI_LABEL)) { ret ~= ", label = " ~UDA.label.to!string; } ret ~= " | "; } ret ~= "]"; } ret ~= "\n"; }} return ret; } void main() { import std.stdio; Node node; node.generateUI().writeln; }
Comment #1 by robert.schadek — 2024-12-13T19:03:18Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17905 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB