www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10020] New: Error: cannot modify struct this Slot with immutable members

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: jens.k.mueller gmx.de


--- Comment #0 from jens.k.mueller 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: -------
May 03 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10020


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim maxim-fomin.ru> 2013-05-03 04:34:13 PDT
---
Yes, this is known issue and was reported several times. Error message is
correct and refers to AA druntime implementation opaque data structure which is
hidden from user.

Root case (plus variations with inout, opEquals, AA arrays, etc...):

struct S
{
    this(this){}
}

struct SS
{
    const S s;
}

void main()
{
}

I think diagnostic shouldn't be fixed here because it is a design problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10020



--- Comment #2 from jens.k.mueller gmx.de 2013-05-03 04:43:13 PDT ---
(In reply to comment #1)
 Yes, this is known issue and was reported several times. Error message is
 correct and refers to AA druntime implementation opaque data structure which is
 hidden from user.
 
 Root case (plus variations with inout, opEquals, AA arrays, etc...):
 
 struct S
 {
     this(this){}
 }
 
 struct SS
 {
     const S s;
 }
 
 void main()
 {
 }
 
 I think diagnostic shouldn't be fixed here because it is a design problem.
Many thanks for the prompt reply. Can you make this report a duplicate then? I haven't found related issues. The problem is then the AA implementation, right? Any schedule on when it will be fixed? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 03 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10020


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #3 from Maxim Fomin <maxim maxim-fomin.ru> 2013-05-03 05:15:12 PDT
---
Marked as duplicate. After lurking through bugzilla search I found many issues
close to this one, but 8954 seems the most relevant.

*** This issue has been marked as a duplicate of issue 8954 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2013