digitalmars.D.learn - Shouldn't duplicate functions be caught by DMD?
- Andrej Mitrovic (34/34) May 07 2011 I'm not talking about function overloading, but functions with the same ...
- bearophile (4/5) May 08 2011 I suggest to add an enhancement request in Bugzilla. Bugzilla entries ar...
-
Stewart Gordon
(6/9)
May 08 2011
I'm not talking about function overloading, but functions with the same
parameters inside the same class definition:
class Foo
{
int foo(int i)
{
return 1;
}
int foo(int i)
{
return 1;
}
void bar()
{
foo(1);
}
}
void main()
{
auto foo = new Foo();
}
Errors:
test.d(19): Error: function test.Foo.foo called with argument types:
((int))
matches both:
test.Foo.foo(int i)
and:
test.Foo.foo(int i)
If you comment out the call to foo(), and compile via -c -w -wi, no errors will
be emitted. Only later when you try to use the object file you'll get a linker
error:
fset 003C4H Record Type 00C3
Error 1: Previous Definition Different : _D4test3Foo3fooMFiZi
--- errorlevel 1
I think the compiler should check catch these mistakes at compile-time.
May 07 2011
Andrej Mitrovic:I think the compiler should check catch these mistakes at compile-time.I suggest to add an enhancement request in Bugzilla. Bugzilla entries are a form of "voting" by themselves too. Bye, bearophile
May 08 2011
On 08/05/2011 09:41, bearophile wrote:Andrej Mitrovic:<snip> One should not file stuff in Bugzilla without first looking to see whether it's already there. And this one is: http://d.puremagic.com/issues/show_bug.cgi?id=1003 Stewart.I think the compiler should check catch these mistakes at compile-time.I suggest to add an enhancement request in Bugzilla. Bugzilla entries are a form of "voting" by themselves too.
May 08 2011








Stewart Gordon <smjg_1998 yahoo.com>