[Issue 10013] `inout` constructor sometimes fails to create immutable object

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 4 01:09:10 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10013



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-04 01:09:08 PDT ---
These are the designed behavior.

1. If the inout constructor has inout parameters, the created object is
restricted to the argument qualifiers - it is same as normal inout functions.
So:

    auto c0 = new immutable C(cast(immutable int[]) null); // OK

constructor call creates inout object and it is implicitly translated to
immutable by the immutable arguments.

1.5 'null' literal is normally treated as a mutable data, so

    auto c2 = new immutable C(null); // Error (line 11)

constructor call creates mutable C object, but it is not convertible to
immutable.


2. To convert the created object to any qualifier, the constructor should have
'pure' attribute at least. So:

    auto c1 = new immutable C(); // Error (line 10)

fails to compile.

-- 
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