[Issue 19854] New: Code stops Compiling when removing pragma(msg, | probably related to UDAs on enums
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 8 15:45:06 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19854
Issue ID: 19854
Summary: Code stops Compiling when removing pragma(msg, |
probably related to UDAs on enums
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: puremagic at zoadian.de
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;
}
--
More information about the Digitalmars-d-bugs
mailing list