https://issues.dlang.org/show_bug.cgi?id=18711

          Issue ID: 18711
           Summary: Suggest to slice a static array when the called
                    function would accept it
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: greensunn...@gmail.com

>From the NG
(https://forum.dlang.org/post/migoytwwjmzuzmxsu...@forum.dlang.org).
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.

--

Reply via email to