[Issue 22711] New: Effect of template UDAs on instance members is undocumented

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 28 20:54:01 UTC 2022


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

          Issue ID: 22711
           Summary: Effect of template UDAs on instance members is
                    undocumented
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dlang.org
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

When a UDA is attached to a template declaration, and that template is
instantiated, the UDA is automatically attached to each of that template
instance's direct members:

---
@("uda") template Example(T)
{
    struct S { int x; }
    int n;
    void fun() {};
}

import std.traits: hasUDA;

static assert(hasUDA!(Example!int.S, "uda"));
static assert(hasUDA!(Example!int.n, "uda"));
static assert(hasUDA!(Example!int.fun, "uda"));

// does not apply to members of members
static assert(!hasUDA!(Example!int.S.x, "uda"));
---

However, this behavior is not documented in the language spec.

--


More information about the Digitalmars-d-bugs mailing list