Issue 11221 - C-style struct literals in associative array literals too
Summary: C-style struct literals in associative array literals too
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-10 14:04 UTC by bearophile_hugs
Modified: 2021-01-24 07:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-10-10 14:04:33 UTC
struct MyStruct {
    int x;
}
void main() {
    MyStruct[string] aa1 = ["A": MyStruct(1),
                            "B": MyStruct(2),
                            "C": MyStruct(3)]; // OK
    MyStruct[string] aa2 = ["A": {1}, "B": {2}, "C" : {3}]; // Error
}


DMD 2.064 alpha gives:

test.d(8): Error: not an associative array initializer
Comment 1 mhh 2021-01-24 07:26:24 UTC
Old + Invalid