[Issue 7542] inout parameter contravariant should be allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 19 05:05:59 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7542
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |timon.gehr at gmx.ch
--- Comment #2 from timon.gehr at gmx.ch 2012-02-19 05:05:58 PST ---
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
--
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