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: nob...@puremagic.com
          Reporter: snarwin+bugzi...@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.

--

Reply via email to