digitalmars.D.bugs - [Issue 1417] New: templated final const member can't be assigned in constructor from the const const argument
- d-bugmail puremagic.com (76/76) Aug 12 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1417
- d-bugmail puremagic.com (12/12) Nov 18 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1417
- d-bugmail puremagic.com (11/11) Nov 18 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1417
http://d.puremagic.com/issues/show_bug.cgi?id=1417 Summary: templated final const member can't be assigned in constructor from the const const argument Product: D Version: 2.003 Platform: PC OS/Version: Linux Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: baryluk mpi.int.pl ---- 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. --
Aug 12 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1417 Witold Baryluk <baryluk smp.if.uj.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #1 from Witold Baryluk <baryluk smp.if.uj.edu.pl> 2009-11-18 13:27:44 PST --- Closing, as #1410 is already working correctly, and I think this also. Tested in v2.032. Probably working since 2.022. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 18 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1417 Witold Baryluk <baryluk smp.if.uj.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |1410 --- Comment #2 from Witold Baryluk <baryluk smp.if.uj.edu.pl> 2009-11-18 13:28:20 PST --- Closing, as #1410 is already working correctly, and I think this also. Tested in v2.032. Probably working since 2.022. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 18 2009