import std .stdio ;
template MGettor (alias Fld) {
typeof(Fld) opCall () {
writefln("getter");
return Fld;
}
}
class Foo {
int a = 1 ,
b = 2 ;
mixin MGettor!(a) geta;
mixin MGettor!(b) getb;
}
void main () {
auto foo = new Foo;
writefln(foo.geta);
writefln(foo.getb);
}
error from dmd:
parse a
semantic a
semantic2 a
semantic3 a
code a
generating code for function 'opCall'
generating code for function 'opCall'
generating code for function 'main'
foo dotexp mixin MGettor!(a);
Internal error: e2ir.c 772
Comment #1 by braddr — 2006-10-16T03:02:01Z
This is the same internal error as bug 354 which also deals with template usage so it might be a dup. The code samples are similar, though definitly not the same.
I reduced the test case a bit:
import std.stdio;
template MGettor () {
void opCall () {}
}
class Foo {
mixin MGettor!() geta;
}
void main () {
Foo foo = new Foo;
writefln(foo.geta);
}