Bug 9038 – Template mixin identifier as template alias parameter issue
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-11-17T04:01:00Z
Last change time
2012-11-18T16:45:50Z
Assigned to
nobody
Creator
japplegame
Comments
Comment #0 by japplegame — 2012-11-17T04:01:47Z
Compiler doesn't want to compile this code:
mixin template node() {
static if(is(this == struct))
alias typeof(this)* E;
else
alias typeof(this) E;
E prev, next;
}
struct list(alias N) {
N.E head;
N.E tail;
}
class A {
mixin node L1;
mixin node L2;
}
list!(A.L1) l1;
list!(A.L2) l2;
Discussion is here: http://forum.dlang.org/thread/[email protected]
Comment #1 by japplegame — 2012-11-18T08:18:53Z
Also another bug seems to have the same reason:
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.
Comment #2 by k.hara.pg — 2012-11-18T16:45:50Z
*** This issue has been marked as a duplicate of issue 9026 ***