Bug 24745 – Better error message when creating an associative array with the wrong syntax

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-09-04T17:09:49Z
Last change time
2024-11-17T00:08:21Z
Keywords
pull
Assigned to
No Owner
Creator
Lance Bachmeier

Comments

Comment #0 by lance — 2024-09-04T17:09:49Z
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.
Comment #1 by dlang-bot — 2024-09-09T11:00:57Z
@royalpinto007 updated dlang/dmd pull request #16832 "fix 24745 - improve associative array syntax error message" fixing this issue: - fix Bugzilla 24745 - improve associative array syntax error message Signed-off-by: royalpinto007 <[email protected]> fix 24745 - issue line Signed-off-by: royalpinto007 <[email protected]> https://github.com/dlang/dmd/pull/16832
Comment #2 by dlang-bot — 2024-11-17T00:08:21Z
dlang/dmd pull request #16832 "fix Bugzilla 24745 - improve associative array syntax error message" was merged into master: - d4b85e9827a85bfe4f55b0fbd1c487fed7b051b9 by royalpinto007: fix Bugzilla 24745 - improve associative array syntax error message Signed-off-by: royalpinto007 <[email protected]> https://github.com/dlang/dmd/pull/16832