www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15335] New: getSymbolsByUDA fails if type has private members

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

          Issue ID: 15335
           Summary: getSymbolsByUDA fails if type has private members
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ryan rcorre.net

getSymbolsByUDA will fail on a type that has _any_ private members (even if
they are not marked with an attribute).

Case:
---
import std.traits;

struct mark { }

struct S {
   mark int a;
  private int b;
}

static assert(getSymbolsByUDA!(S, mark).length == 1);
---


Error:
---
Press ENTER or type command to continue
/usr/include/dlang/dmd/std/traits.d(6701): Error: struct type.S member b is not
accessible
/usr/include/dlang/dmd/std/meta.d(546): Error: template instance
std.traits.getSymbolsByUDA!(S, mark).F!"b" error instantiating
/usr/include/dlang/dmd/std/meta.d(553):        instantiated from here:
staticMap!(StringToSymbol, "b")
/usr/include/dlang/dmd/std/traits.d(6703):        instantiated from here:
staticMap!(StringToSymbol, "a", "b")
/tmp/type.d(10):        instantiated from here: getSymbolsByUDA!(S, mark)
Failed: ["dmd", "-Isrc", "-main", "-unittest", "-debug", "-g", "-v", "-o-",
"/tmp/type.d", "-I/tmp"]
---

--
Nov 14 2015