D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6776 - attributes injected via pure template mixin but not class mixin
Summary: attributes injected via pure template mixin but not class mixin
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-06 04:01 UTC by pelo
Modified: 2012-02-12 15:52 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 pelo 2011-10-06 04:01:43 UTC
import std.stdio;

    class C(T) {
        T val;
    }

    class D {
        mixin C!bool;
    }

    int main() {
        auto d = new D;
        writeln(d.val);
        return 0;
    }

This fails to compile (no val in D), yet if defining C as:

    template C(T) {
        T val;
    }

It works.

This is rather silly as it forces me to write wrapper classes that forward to a template.
Comment 1 Stewart Gordon 2012-02-12 15:52:33 UTC
There's no such thing as a class mixin.  One mixes in template instances, not classes.  Since a class template is just syntactic sugar for a template with an eponymous class as its only member, the compiler expands it to:

    class D {
        class C {
            bool val;
        }
    }

So of course there's no such thing as d.val.