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

--- Comment #0 from Christopher Nicholson-Sauls <> 
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

Maybe all postblits should be this(const this) in the first place?

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to