[Issue 19344] Enum member UDAs & getUDAs throwing an error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 17 17:24:05 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19344

Mr. Smith <mrsmith33 at yandex.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrsmith33 at yandex.ru

--- Comment #1 from Mr. Smith <mrsmith33 at yandex.ru> ---
Have the same bug. Example:

---
import std.traits : getUDAs;
void main(){}
struct Struct {
    int value;
}
enum Enum {
    @Struct(42) first,
}
static assert(getUDAs!(Enum.first, Struct)[0] == Struct(42));
static assert(__traits(getAttributes, Enum.first)[0] == Struct(42)); // this
version always works
---
app.d(7): Error: undefined identifier Struct
app.d(9): Error: template instance std.traits.getUDAs!(cast(Enum)0, Struct)
error instantiating
app.d(9):        while evaluating: static assert((__error)[0] == Struct(42))


However if I swap static asserts it compiles:

---
import std.traits : getUDAs;
void main(){}
struct Struct {
    int value;
}
enum Enum {
    @Struct(42) first,
}
static assert(__traits(getAttributes, Enum.first)[0] == Struct(42));
static assert(getUDAs!(Enum.first, Struct)[0] == Struct(42));
---

--


More information about the Digitalmars-d-bugs mailing list