[Issue 3731] Derived class implicitly convertible to base class with arbitrary change of constancy
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 26 03:56:57 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3731
--- Comment #11 from Stewart Gordon <smjg at iname.com> 2012-03-26 03:57:16 PDT ---
(In reply to comment #10)
> I think you misunderstand. I don't mean because Stala exists,
> Zmienna should be prevented from being mutable, even for cases
> where Stala is not involved. I mean, it should be illegal to have
> a mutable Stala reference point at a Zmienna.
I haven't misunderstood. There's no such thing as a mutable Stala reference.
Because Stala is an immutable class, any reference to a Stala is automatically
immutable. See for yourself:
-----
void main() {
Stala st = new Stala(5);
pragma(msg, typeof(st)); // immutable(Stala)
st = new Stala(4); // errors, because st is immutable
Zmienna zm = st; // accepts-invalid
}
-----
The bug is that DMD allows the implicit conversion of immutable(Stala) to
Zmienna. It's just mb_id in my last example.
--
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