Bug 8723 – Error: function called with argument types:
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-25T05:30:00Z
Last change time
2012-10-21T13:38:55Z
Assigned to
nobody
Creator
maxim
Comments
Comment #0 by maxim — 2012-09-25T05:30:35Z
void foo();
void foo()
{
}
void main()
{
foo(); // here
}
----------------------
hello.d(10): Error: function hello.foo called with argument types:
(())
matches both:
hello.foo()
and:
hello.foo()
-----------------------
Clearly it is a bug.
Comment #1 by issues.dlang — 2012-09-25T09:51:18Z
Why is that clearly a bug? You gave two functions with identical function signatures. The only time that you give function prototypes in D are when you're _not_ providing the source (e.g. inside of .di files or version(D_Ddoc) blocks).
Comment #2 by maxim — 2012-09-25T11:35:45Z
(In reply to comment #1)
> Why is that clearly a bug? You gave two functions with identical function
> signatures. The only time that you give function prototypes in D are when
> you're _not_ providing the source (e.g. inside of .di files or version(D_Ddoc)
> blocks).
No, I gave one function prototype (declaration) and one function definition with similar name and type. The former has to be binded to the latter. This is how C works and D should follow it in this regard. There is no reason for assuming that prototypes and definitions are separated between different modules and no reason for making feigned ambiguity between function body and its own declaration.
Comment #3 by maxim — 2012-09-25T11:37:57Z
By the way, following code is not compiled either (for the same reason):
struct S;
struct S {}
void main()
{
}
Comment #4 by bearophile_hugs — 2012-09-25T12:12:49Z
According to D specs I think there are no bugs here. So at best those are two enhancement requests.
Comment #5 by issues.dlang — 2012-09-25T13:10:26Z
And why on earth would you _need_ a prototype? This isn't C. We're not forced to declare functions higher up in a file before using them. Ideally, prototypes wouldn't even _exist_. They're an artifact of C's poor compilation model.
Unfortunately, they're necessary for .di files, so we have them, but there's no reason whatsoever to be declaring a prototype in a .d file.