www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12729] New: mixins don't work in traits

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

          Issue ID: 12729
           Summary: mixins don't work in traits
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: vlevenfeld gmail.com

const bool has_attribute (T, string member, alias attribute) ()
{
  // ok
    mixin(
      `foreach (type; __traits (getAttributes, T.`~member~`))`
        `static if (is (type == attribute))`
          `return true;`
    );
  // ok
    foreach (type; mixin(`__traits (getAttributes, T.`~member~`)`))
      static if (is (type == attribute))
        return true;
  // doesn't compile, member is not accessible error
    foreach (type; __traits (getAttributes, mixin(`T.`~member)))
      static if (is (type == attribute))
        return true;
  return false;
}

--
May 10 2014