Comment #0 by witold.baryluk+d — 2007-08-13T00:32:04Z
----
import std.stdio;
class B(T) {
T z;
this(T _z) {
z = _z;
}
}
alias B!(int) Bi;
alias const(B!(int)) Bic;
//static assert(!(is(typeof(Bi) == typeof(Bi)))); // fails! (see #1410)
class A {
// final const(Bi) x; // works
// final const(Bic) x; // works
final const(B!(int)) x; // doesn't
// final Bic x; // also doesn't (see #1410)
this(const const(B!(int)) b) {
x = b; // Error: cannot implicitly convert expression (_x)
// of type const B to pr3.B!(int).B
// x.z = 0; // fails. good
}
const void print() {
writefln(x.z);
}
//void print2() {
//x = new const(B!(int))(6) // fails. good
//x.z = 6; // fails. good
//}
}
void main() {
const(B!(int)) b = new const(B!(int))(5);
A a = new A(b);
a.print(); // prints 5
}
----
similar problem:
----
class B(T) {
T z;
}
alias B!(int) Bi;
alias const(B!(int)) Bic;
//static assert(!(is(typeof(Bi) == typeof(Bi)))); // fails! (see #1410)
class A {
// final const(Bi) x; // works
// final const(Bic) x; // works
final const(B!(int)) x; // doesn't
// final Bic x; // also doesn't (see #1410)
// const(B!(int)) x; // works
this() {
x = new const(Bi)(); // Error: cannot implicitly convert expression (_x)
// of type const B to pr3.B!(int).B
// x = new const(B!(int))(); // works
}
}
void main() {
A a = new A();
}
----
This bug prevents writing strictly const code with templates.
Comment #1 by witold.baryluk+d — 2009-11-18T13:27:44Z
Closing, as #1410 is already working correctly, and I think this also. Tested in v2.032. Probably working since 2.022.
Comment #2 by witold.baryluk+d — 2009-11-18T13:28:20Z
Closing, as #1410 is already working correctly, and I think this also. Tested in v2.032. Probably working since 2.022.