www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14977] New: Struct initializer doesn't work inside AA

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

          Issue ID: 14977
           Summary: Struct initializer doesn't work inside AA initializer
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: japplegame gmail.com

struct Foo {
    int a;
}

void main() {
    // compiles
    Foo[] arr = [
        {a: 1},
        {a: 2}
    ];

    // compiles
    Foo[int] aa1 = [
        1: Foo(),
        2: Foo()
    ];

    // Error: not an associative array initializer
    Foo[int] aa2 = [
        1: {a: 1},
        2: {a: 2}
    ];
}

--
Aug 29 2015