[Issue 12663] New: Wrong error message for mutation of immutable static array

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Apr 27 06:31:16 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12663

          Issue ID: 12663
           Summary: Wrong error message for mutation of immutable static
                    array
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

immutable static int[] data = [1];
static this() {
    data.length++;
}
void main() {}


DMD 2.066alpha gives an error message that is both wrong in contents and refers
to the wrong line:

test2.d(1,31): Error: constant 1u is not an lvalue


Expected is an error message like:

test2.d(3,5): Error: cannot modify immutable expression data

--


More information about the Digitalmars-d-bugs mailing list