www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7768] New: More readable template error messages

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

           Summary: More readable template error messages
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



This code has bad usage of std.conv.parse template function.
But raised error message is less readable.

import std.conv;
void test1()
{
    int value;
    parse(value);
    // Error: template std.conv.parse(Target,Source)
    //   if (isSomeChar!(ElementType!(Source)) && isIntegral!(Target))
    //   does not match any function template declaration
    // Error: template std.conv.parse(Target,Source)
    //   if (isSomeChar!(ElementType!(Source)) && isIntegral!(Target))
    //   cannot deduce template function from argument types !()(int)
}

parse template function is overloaded, so printing template parameter and
constraint is much confusing.
It should print like follows:

    // Error: template std.conv.parse does not match any
    //   function template declaration
    // Error: template std.conv.parse cannot deduce template function
    //   from argument types !()(int)
}

"matches more than one template declaration" error message has same problem.

void foo(T)(T val) if (is(T : int)) {}
void foo(T)(T val) if (is(T : long)) {}
void test2()
{
    foo(10);
    // Error: template test.foo(T) if (is(T : int)) foo(T) if (is(T : int))
    //   matches more than one template declaration,
    //   test.d(29):foo(T) if (is(T : int)) and
    //   test.d(30):foo(T) if (is(T : long))

should print:
    // Error: template test.foo matches more than one template declaration,
    //   test.d(29):foo(T) if (is(T : int)) and
    //   test.d(30):foo(T) if (is(T : long))
}

If there is only one template function, keeping specialized error message is
better.

void bar(T)(T val) if (is(T : int)) {}
void test3()
{
    bar("abc");
    // Error: test.bar does not match any function template declaration
    // Error: template test.bar(T) if (is(T : int)) cannot deduce
    //   template function from argument types !()(string)
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 24 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7768


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/839

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7768


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei metalanguage.com



*** Issue 2696 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7768




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/28c0da04f3640f3313b1229161232fee53ca1cd2


Issue 7768 - More readable template error messages

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7768


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2012