[Issue 7542] inout parameter contravariant should be allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 19 06:11:27 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7542
--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2012-02-19 06:11:25 PST ---
(In reply to comment #2)
> This pull breaks the type system:
>
> void main(){
> // conversion from void function(int*) to void function(inout(int)*):
> void function(inout(int)*) wfp = function(int*)(*p = 1;}
> immutable int x = 0;
> wfp(&x); // mutates x
> }
>
> The title of the bug report is correct though, contravariance is safe.
>
> Those are the safe conversions:
> mfp = wfp; // match inout as mutable
> wfp = cfp; // inout is a subtype of const
> cfp = wfp; // match inout as const
> ifp = wfp; // match inout as immutable
You are right, and this fix doesn't block 7543.
--
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