digitalmars.D.bugs - [Issue 15752] New: Diagnostic: Better Error Message for Assigning
- via Digitalmars-d-bugs (34/34) Mar 03 2016 https://issues.dlang.org/show_bug.cgi?id=15752
https://issues.dlang.org/show_bug.cgi?id=15752 Issue ID: 15752 Summary: Diagnostic: Better Error Message for Assigning Incorrect AA Empty Value Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: jack jackstouffer.com Because of the use of [] to enclose AA assignment, one could be forgiven in accidentally doing something like this: void main() { int[int] a = []; } Which results in the very unhelpful message: Error: can't have associative array key of void Of course, the right answer is to use null, but again, the similarities with array literals one could be expected to make this mistake. The error message is also different when trying to do this for an optional function parameter. void func(int[int] b = []) { } void main() { func(); } Error: cannot implicitly convert expression ([]) of type void[] to int[int] The message should be something like this: Error: can't have associative array key of void. Perhaps you meant to initialize an empty AA with null? --
Mar 03 2016