Hi,

I do not understand why struct initializer works for arrays but not for
associative arrays:

struct Bar
{
    string s;
}

struct Foo
{
    Bar[string] asso;
    Bar[] arr;
}

void main()
{
    Foo foo = {
        arr: [{s: "123"}],
        asso: ["0": {s: "123"}] // does not work
    };
}

The coding for both types of arrays looks very similiar:
https://github.com/dlang/dmd/blob/9ed779a7d68d2ac489338cc4758c10d0cb169b39/src/dmd/initsem.d#L634

I cannot spot the difference.

Kind regards
André

Reply via email to