www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7853] New: Almost useless error message related to postblit with AA of const struct

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

           Summary: Almost useless error message related to postblit with
                    AA of const struct
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ibisbasenji gmail.com



2012-04-07 17:15:16 PDT ---
Given the code:

----------
module bug;

struct S { this ( this ) {} }
struct Z { const( S )[ int ] broken; }
void main () {
    foreach ( i,x ; Z().broken ) {}
}
----------

The compiler correctly errors, but does not provide enough information in the
error message:
 bug.d(3): Error: function bug.S.__postblit () is not callable using argument
types ()
 Error: *&this is not mutable
 Error: this is not mutable
 Error: this is not mutable
While correct, it does not reference the line with the foreach, which is what triggers the problematic postblit. The fix is obvious: redefine postblit as this(const this); but it isn't always obvious when looking at hundreds of lines of code. I know, because I just dealt with it myself, and spent at least an hour figuring out what was triggering it so I could decide whether the fix was appropriate. Maybe all postblits should be this(const this) in the first place? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 07 2012