What    |Removed                     |Added
           Severity|normal                      |critical
           Keywords|spec                        |accepts-invalid
            Summary|Inconsistent behavior with  |Creating new struct with
                   |const/immutable struct      |literal bypasses
                   |members                     |immutability of members if
                   |                            |struct is in array

------- Comment #1 from  2009-04-01 15:06 -------
Upon thinking about this some more, it's pretty clear that one should *not* be
able to change the value in an existing memory location by creating a whole new
struct, i.e. the following is bad:

struct Pair {
    immutable uint g1;
    uint g2;

void main() {
    Pair[1] stuff;
    stuff[0] = Pair(1, 2);  // Modify immutable by rebinding whole struct.

Note that the same thing happens if stuff is a dynamic array instead of a
static array.  Upping severity, giving more descriptive title.


Reply via email to