D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7558 - (D1 only) Useless 'cannot implicitly convert' errors when number of function arguments is wrong
Summary: (D1 only) Useless 'cannot implicitly convert' errors when number of function ...
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2012-02-21 07:14 UTC by Don
Modified: 2019-11-07 08:08 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2012-02-21 07:14:03 UTC
When the compiler reports errors of the form "expected 6 function arguments, not 5",
trying to implicitly convert the first 5 arguments generates spurious "cannot implicitly convert XXX to YYY" errors.
To add value, the compiler could try to work out which argument is missing; unless it does that, it shouldn't attempt the conversion.
Comment 1 Walter Bright 2012-02-21 11:15:36 UTC
An example demonstrating this would be useful.
Comment 2 Don 2012-02-21 13:29:21 UTC
void bug7558(string x, int y, double z) {}

void main()
{
   bug7558(4, 2.2);
}   

DMD 1.073 / 2.057:

bug.d(5): Error: function bug.bug7558 (char[],int,double) does not match paramet
er types (int,double)
bug.d(5): Error: cannot implicitly convert expression (4) of type int to char[]
bug.d(5): Error: cannot implicitly convert expression (2.2) of type double to in
t
bug.d(5): Error: expected 3 function arguments, not 2


But the second and third errors don't happen in 2.058. Looks like this is a D1 only bug -- a patch that didn't get merged?
Comment 3 hsteoh 2014-07-30 01:03:22 UTC
Seems to have been fixed in git HEAD:
-----
$ cat test.d
void bug7558(string x, int y, double z) {}

void main()
{
   bug7558(4, 2.2);
}   
$ dmd test.d
test.d(5): Error: function test.bug7558 (string x, int y, double z) is not callable using argument types (int, double)
$ 
-----
No extraneous errors were given.
Comment 4 yebblies 2014-07-30 12:34:11 UTC
(In reply to hsteoh from comment #3)
> Seems to have been fixed in git HEAD:
> -----
> $ cat test.d
> void bug7558(string x, int y, double z) {}
> 
> void main()
> {
>    bug7558(4, 2.2);
> }   
> $ dmd test.d
> test.d(5): Error: function test.bug7558 (string x, int y, double z) is not
> callable using argument types (int, double)
> $ 
> -----
> No extraneous errors were given.

Did you test it with D1?
Comment 5 hsteoh 2014-07-30 15:10:54 UTC
Hmph, didn't notice it was marked for both D1 and D2. Should this be reopened for D1 then?
Comment 6 yebblies 2014-07-30 15:15:58 UTC
(In reply to hsteoh from comment #5)
> Hmph, didn't notice it was marked for both D1 and D2. Should this be
> reopened for D1 then?

Probably.
Comment 7 RazvanN 2019-11-07 08:08:12 UTC
D1 is no longer supported/ Closing as WORKSFORME.