[Issue 24745] New: Better error message when creating an associative array with the wrong syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 4 17:09:49 UTC 2024


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: nobody at puremagic.com
          Reporter: lance at lancebachmeier.com

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.

--


More information about the Digitalmars-d-bugs mailing list