https://issues.dlang.org/show_bug.cgi?id=24745
Issue ID: 24745
Summary: Better error message when creating an associative
array with the wrong syntax
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
If you accidentally do this when creating an AA
int[int] f = {1: 1, 2: 2};
The error message is confusing:
Error: comma expected separating field initializers
Error: expression expected, not `:`
In this case, the error message could include something to indicate that [] are
used to create an associative array. It's also unclear what the error message
in its current form means, since {1: 1, 2: 2} is designated initializer syntax.
The only problem is that 1 and 2 are not valid names.
--