Summary: to!() needs a template constraint
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from Jonathan M Davis <> 2010-10-01 22:58:28 
PDT ---
The following program

import std.conv;
import std.stdio;

void main()
    dchar[7] numStr = "1234567";


fails compilation with this error

Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) &&
isSomeString!(T) && isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S)))
toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) &&
isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S))) matches more than
one template declaration,
if (isStaticArray!(S)) and
if ((is(S : const(wchar)[]) || is(S : const(dchar)[])) && !isSomeString!(T))
jmda...@lyonel ~/Programming/D/datetime [master]$ gvim

The error gives no indication whatsoever where the actual error is. The problem
is not in to!() but in the code that tried to instantiate to!(), and the error
gives no way to find that code. Ideally, bug # 4970 would be fixed and the
error would correctly indicate where to!() was used, but really, to!() should
have a template constraint of its own. As it stands, it's guaranteed that any
error instantiating to!() is not going to report the actual location of the
error. Copying or moving toImpl!()'s template constraint to to!() would fix the
problem quite easily, and I don't see much reason not to do it. It would
certainly make errors with using to!() easier to fix.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to