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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 30 05:34:46 PDT 2013


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

           Summary: `inout` constructor sometimes fails to create
                    immutable object
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-04-30 16:34:45 MSD ---
---
class C
{
    this() inout { }
    this(inout int[]) inout {  }
}

void main()
{
    auto c0 = new immutable C(cast(immutable int[]) null); // OK
    auto c1 = new immutable C(); // Error (line 10)
    auto c2 = new immutable C(null); // Error (line 11)
}
---

dmd output:
---
main.d(10): Error: inout constructor main.C.this creates inout object, not
immutable
main.d(11): Error: inout constructor main.C.this creates mutable object, not
immutable
---

Partial workaround:
Mark constructor as `pure` or `immutable` if possible.

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