www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2720] New: Function resolution failure error message is unclear

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

           Summary: Function resolution failure error message is unclear
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jarrett.billingsley gmail.com


void foo(int x) { }
foo(4.5);

Gives the error:

dtest.d(11): function dtest.main.foo (int) does not match parameter types
(double)

I've been using DMD for over 4 years and I still have trouble interpreting the
error message.  I always think it's the other way around (I expect what is
passed to be on the left and the function's signature to be on the right).  It
also goes against the convention I've seen used elsewhere where parameters are
what are defined in the function header and arguments are the values passed to
the parameters (so (double) is the list of argument types, not parameter
types).

Something like:

dtest.d(11): Incompatible argument types (double) for function dtest.main.foo
(expected (int))

Would be much more helpful.

I'll leave it to Stewie to put a keyword on here if he wants.  I'm afraid I'll
pick the wrong one.


-- 
Mar 09 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2720


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED



We have a better error message now!

testx.d(3): Error: function testx.foo (int x) is not callable using argument
typ
es (double)
testx.d(3): Error: cannot implicitly convert expression (4.5) of type double to
int

Fixed in D1 and D2 (1.068 & 2.053)

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