[Issue 1873] New: structs with at least one immutable member are completely immutable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 27 00:26:19 PST 2008


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

           Summary: structs with at least one immutable member are
                    completely immutable
           Product: D
           Version: 2.011
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: ludwig at informatik.uni-luebeck.de


The following code fails to compile, although 'x' should be mutable:

struct S {
        invariant int dummy; // const gives the same result
        int x;
}

int main(){
        S s;
        s.x = 1; // error: cannot modify struct with immutable members
        return 0;
}


-- 



More information about the Digitalmars-d-bugs mailing list