[Issue 8726] About immutable and const constructors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 26 00:15:49 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8726
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-04-26 00:15:48 PDT ---
In 2.063, qualified constructor will be supported properly.
This code would work in 2.063.
class A
{
int x;
this() immutable { x = 42; }
this() { x = 13; }
}
class B
{
int x;
this() const { x = 42; }
this() { x = 13; }
}
void main()
{
A ma = new A;
assert(ma.x == 13);
//immutable A ia = new A;
//--> Error: cannot implicitly convert expression (new A)
// of type test.A to immutable(A)
immutable A ia = new immutable A;
assert(ia.x == 42);
const B mb = new B;
assert(mb.x == 13);
const B cb = new const B;
assert(cb.x == 42);
//immutable B ib = new B;
//--> Error: cannot implicitly convert expression (new B)
// of type test.B to immutable(B)
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list