D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12729 - mixins don't work in traits
Summary: mixins don't work in traits
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-10 16:17 UTC by Vlad Levenfeld
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vlad Levenfeld 2014-05-10 16:17:01 UTC
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;
}
Comment 1 monarchdodra 2014-05-10 19:16:02 UTC
Could you provide the use case that triggers the error? I can't reproduce it.
Comment 2 Vlad Levenfeld 2014-05-22 20:24:05 UTC
my apologies, I didn't understand how the mailing system worked at the time that I posted this and only now saw your comment - the use case has since been thoroughly paved over.
Comment 3 monarchdodra 2014-05-22 21:18:22 UTC
(In reply to Vlad Levenfeld from comment #2)
> the use case has since been thoroughly paved over.

Hum... Well, if we can't reproduce the issue, we'll have to close this.
Comment 4 basile-z 2019-02-13 04:03:23 UTC
not resolvable as is