Bug 275 – Undefined identifier in instances of templates with forward mixins

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2006-08-02T17:19:00Z
Last change time
2015-06-09T05:11:40Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
bruno.do.medeiros+deebugz
Blocks
340

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2006-08-02T17:19:55Z
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; } ----