[Issue 21122] New: hasUDAs/getUDAs/getSymbolsByUDA fails on local symbol UDAs with enum values
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 5 12:09:35 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21122
Issue ID: 21122
Summary: hasUDAs/getUDAs/getSymbolsByUDA fails on local symbol
UDAs with enum values
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: zan77137 at nifty.com
This code doesn't work:
--------------------------------------
import std.traits;
enum B;
void main()
{
enum A;
struct S { @A int a; }
enum E { @A a, @B b }
static assert(hasUDA!(S.a, A));
// Error: undefined identifier A ... while evaluating:
static assert(hasUDA!(E.a, A));
static assert(hasUDA!(E.b, B));
static assert(is(getUDAs!(S.a, A)[0] : A));
// Error: static assert: is(getUDAs!(cast(E)0, A)[0] : A) is false
static assert(is(getUDAs!(E.a, A)[0] : A));
static assert(is(getUDAs!(E.b, B)[0] : B));
static assert(getSymbolsByUDA!(S, A).length == 1);
// Error: static assert: 0LU == 1LU is false
//static assert(getSymbolsByUDA!(E, A).length == 1);
static assert(getSymbolsByUDA!(E, B).length == 1);
}
--------------------------------------
The following issue is similar, but the previous example succeeds in S, but
fails in E.
https://issues.dlang.org/show_bug.cgi?id=15335
--
More information about the Digitalmars-d-bugs
mailing list