[Issue 12678] New: Better multiple field initialization error

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Apr 28 17:27:53 PDT 2014


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

          Issue ID: 12678
           Summary: Better multiple field initialization error
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

const struct Foo {
    int field;
    int Field;
    this(int x) {
        Field = x;
        Field = x;
        foreach (i; 0 .. 5)
            field = x;
    }
}
void main() {}


Gives with DMD 2.066alpha:

temp.d(6,9): Error: multiple field Field initialization
temp.d(8,13): Error: field field initializing not allowed in loops or after
labels


But I think something similar to this is better:

temp.d(6,9): Error: multiple const 'Field' initialization is not allowed
temp.d(8,13): Error: const 'field' initialization isn't allowed in loops or
after labels

--


More information about the Digitalmars-d-bugs mailing list