[Issue 10020] New: Error: cannot modify struct this Slot with immutable members

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 3 02:32:57 PDT 2013


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

           Summary: Error: cannot modify struct this Slot with immutable
                    members
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jens.k.mueller at gmx.de


--- Comment #0 from jens.k.mueller at gmx.de 2013-05-03 02:32:52 PDT ---
The following code produces the compiler error "Error: cannot modify struct
this Slot with immutable members". I compiled using dmd v2.062 on Linux with
"dmd file.d". I expected a proper diagnostics message on how to fix the problem
or what's the root of the problem. Note, there are no line numbers.

file test.d
---
struct StructA                                                                  
{                                                                               
    // commenting out postblit makes the error go away                          
    this(this) inout                                                            
    {                                                                           
    }                                                                           
}                                                                               

struct StructB                                                                  
{                                                                               
    // commenting out opEquals makes the error go away                          
    bool opEquals()(auto ref const StructB rhs) const                           
    {                                                                           
        return true;                                                            
    }                                                                           
}                                                                               

struct StructC                                                                  
{                                                                               
    StructA[int] _structA; // commenting out this makes the error go away       
    StructB _structB;      // commenting out this makes the error go away       
}                                                                               

void main(){}
---

Besides improving the compiler diagnostics it is also helpful to understand the
issue. I assume it's some const problem.

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