[Issue 2339] New: Inconsistent behaviour referring to template mixin member at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 6 10:03:34 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2339

           Summary: Inconsistent behaviour referring to template mixin
                    member at compile time
           Product: D
           Version: 1.035
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: matti.niemenmaa+dbugzilla at iki.fi


All four cases in the code below should not assert, yet the first two do and
the fourth doesn't even compile. I'm marking this as "blocker" because there's
no workaround that I can find and I really need the fourth case to work.

It may be that this is a combination of two bugs: the string mixin apparently
mangles the identifier into "this.x", which may explain the fourth case. The
first two don't make any sense in light of the third, though.

template Check(alias name) { const Check = is(typeof(name)); }

template FooTemplate() { int x; }

class X {
        mixin FooTemplate FooMixin;

        // false:
        // static assert (is(typeof(FooMixin.x)));
        // static assert (is(typeof(mixin("FooMixin.x"))));

        // true:
        static assert (Check!(FooMixin.x));

        // doesn't compile:
        // asdf.d(20): Error: 'this' is only defined in non-static member
functions, not asdf
        // asdf.d(20): Error: this for x needs to be type X not type int
        // asdf.d(20): template instance Check!(this.x) does not match any
template declaration
        // asdf.d(20): static assert  (Check!(this.x)) is not evaluatable at
compile time

        static assert (Check!(mixin("FooMixin.x")));
}


-- 



More information about the Digitalmars-d-bugs mailing list