www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13372] New: traits parent shows template function as its own


          Issue ID: 13372
           Summary: traits parent shows template function as its own
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: ellery-newcomer utulsa.edu

Passing an instantiated eponymous function template to __traits(parent,) yields
a symbol that points to the function passed in. In G in the following code, I'm
seeing this behavior:

  f       __traits(parent, f)
------  ----------------------
a              tok
b!int.c        __T1bTiZ
t!int          t


import  std.typetuple;

int a(int i) {
    return i;

template b(T) {
    int c(T t) {
        return 1;

int t(T)(T g) {
    return 1;

template G(alias f) {
    static assert(is(typeof(f) == function));
    pragma(msg, __traits(identifier, f));
    alias Parent = TypeTuple!(__traits(parent, f))[0];
    pragma(msg, __traits(identifier, Parent));
    static assert(!is(typeof(Parent) == typeof(f)), "I'm my own parent?");

void main(){
    alias y = G!(a);
    alias z = G!(t!int); // fails in here

Aug 24 2014