Bug 20547 – Wrong error message when trying to "new" an associative array

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-30T21:32:45Z
Last change time
2020-03-21T03:56:40Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2020-01-30T21:32:45Z
DMD yields poor error messages when trying to allocate a dynamic array: void main() { int[int] a = new int[int]; // need size of rightmost array, not type int int[string] b = new int[string]; // cannot pass type string as a function argument int[string] c = new typeof(b); // new can only create structs, dynamic arrays or class objects, not int[string]'s } a and b should produce the same output as c.
Comment #1 by dlang-bot — 2020-02-06T05:35:55Z
@benjones created dlang/dmd pull request #10768 "fix issue 20547, improve error messages for malformed new expressions" fixing this issue: - fix issue 20547, error messages for bad new expressions https://github.com/dlang/dmd/pull/10768
Comment #2 by dlang-bot — 2020-02-15T00:25:55Z
dlang/dmd pull request #10768 "fix issue 20547, improve error messages for malformed new expressions" was merged into master: - 9d7a9bc47d9b9cc25055c71d875c7675953a8816 by Ben Jones: fix bug 20547 improve error messages for invalid uses of new https://github.com/dlang/dmd/pull/10768