Strange template alias behaviour

Maxim Fomin maxim at maxim-fomin.ru
Sun Nov 18 08:05:49 PST 2012


Reduced:

import std.stdio;

mixin template Foo() {
   string data = "default";
}

class Bar {
   string data;
   mixin Foo f;
}

void check_data(alias M, T)(T obj) {
   writeln(M.stringof);
   writeln(obj.data);
   writeln(obj.f.data);
}

void main() {
   Bar bar = new Bar;
   bar.data = "Bar";
   bar.f.data = "F";

   writeln(bar.data);
   writeln(bar.f.data);

   check_data!(Bar)(bar);
}

Changing template parameter to Bar.f or bar.f affects value of 
bar.f.data. Seems to be a bug.


More information about the Digitalmars-d-learn mailing list