www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4972] New: to!() needs a template constraint

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4972

           Summary: to!() needs a template constraint
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PDT ---
The following program

import std.conv;
import std.stdio;

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

    writeln(to!long(numStr));
}


fails compilation with this error

/home/jmdavis/Downloaded_Files/dmd/dmd2/linux/bin/../../src/phobos/std/conv.d(95):
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,
/home/jmdavis/Downloaded_Files/dmd/dmd2/linux/bin/../../src/phobos/std/conv.d(217):toImpl(T,S)
if (isStaticArray!(S)) and
/home/jmdavis/Downloaded_Files/dmd/dmd2/linux/bin/../../src/phobos/std/conv.d(588):toImpl(T,S)
if ((is(S : const(wchar)[]) || is(S : const(dchar)[])) && !isSomeString!(T))
jmdavis Lyonel ~/Programming/D/datetime [master]$ gvim
/home/jmdavis/Downloaded_Files/dmd/dmd2/src/phobos/std/conv.d


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

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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4972


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4972


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED





https://github.com/D-Programming-Language/phobos/pull/181

https://github.com/D-Programming-Language/phobos/commit/008300792cc18250106f9419cdf1e18dfa805846#L0L1738

After that, this problem was resolved.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 09 2011