Bug 18711 – Suggest to slice a static array when the called function would accept it

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-04-03T05:20:11Z
Last change time
2022-02-25T10:38:51Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Seb

Comments

Comment #0 by greensunny12 — 2018-04-03T05:20:11Z
From the NG (https://forum.dlang.org/post/[email protected]). The following correctly errors: wchar[10] buffer; toUTF8(buffer); However, the error message is a bit cryptic for newcomers: Error: template `std.utf.toUTF8` cannot deduce function from argument types `!()(wchar[10])`, candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/utf.d(2713): `std.utf.toUTF8(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S))` DMD could detect that toUTF8 would accept `buffer[]` and could suggest this to the user.
Comment #1 by razvan.nitu1305 — 2022-02-25T10:38:51Z
Currently, the compiler shows the failing constraint so I think that this is more than enough.