October 12, 2018
https://issues.dlang.org/show_bug.cgi?id=19303

          Issue ID: 19303
           Summary: hasMember fails to recognize member (interaction with
                    mixin template)
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody@puremagic.com
          Reporter: luis@luismarques.eu

In the code quoted below, there is an inconsistency between these two lines:

    pragma(msg, P.ElementType);
    static assert(hasMember!(P, "ElementType"));

The pragma correctly prints the P.ElementType, but the hasMember assert fails. The interaction with the mixin template suggests this might be a compiler bug, but for now I'm only marking this as a Phobos bug. A workaround would be appreciated.

--

import std.traits;

void main()
{
    alias V = Vec!Bool;
    alias P = Port!(V);
    pragma(msg, P.ElementType);
    static assert(hasMember!(P, "ElementType"));
}

mixin template SignalOps()
{
    static if(hasMember!(typeof(this), "ElementType")) { }
}

struct Bool {}

struct Port(SomeSignal)
{
    mixin SignalOps;

    static if(hasMember!(SomeSignal, "ElementType"))
        alias ElementType = SomeSignal.ElementType;
}

struct Vec(SomeSignal)
{
    alias ElementType = SomeSignal;
}

--