Bug 7558 – (D1 only) Useless 'cannot implicitly convert' errors when number of function arguments is wrong
Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2012-02-21T07:14:03Z
Last change time
2019-11-07T08:08:12Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Don
Comments
Comment #0 by clugdbug — 2012-02-21T07:14:03Z
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 by bugzilla — 2012-02-21T11:15:36Z
An example demonstrating this would be useful.
Comment #2 by clugdbug — 2012-02-21T13:29:21Z
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 by hsteoh — 2014-07-30T01:03:22Z
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 by yebblies — 2014-07-30T12:34:11Z
(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 by hsteoh — 2014-07-30T15:10:54Z
Hmph, didn't notice it was marked for both D1 and D2. Should this be reopened for D1 then?
Comment #6 by yebblies — 2014-07-30T15:15:58Z
(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 by razvan.nitu1305 — 2019-11-07T08:08:12Z