[Issue 275] New: Undefined identifier in instances of templates with forward mixins

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 2 15:19:58 PDT 2006


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

           Summary: Undefined identifier in instances of templates with
                    forward mixins
           Product: D
           Version: 0.163
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: daiphoenix at lycos.com


Undefined identifier in instances of templates with forward mixins. The
following fails to compile:

----
template TplWithMixin() {
        mixin Mnum!();
}

//Error: undefined identifier TplWithMixin!().cnum :
auto a = TplWithMixin!().cnum;

template Mnum() {
        const int cnum = 2;
}
----

If TplWithMixin!().cnum is accessed only inside a function, then no error
occurs. 
But if an instance of TplWithMixin is made outside a function, and before the
mixin template, then the function instances will also fail when accessing
members. This code exemplifies:

-----
template TplWithMixin() {
        mixin Mnum!();
}

void test() {
        //Error: undefined identifier TplWithMixin!().cnum :
        auto a = TplWithMixin!().cnum;
}

// Compiles ok if this line is removed or placed after Mnum :
alias TplWithMixin!() xxx; 

template Mnum() {
        const int cnum = 2;
}
----


-- 




More information about the Digitalmars-d-bugs mailing list