Thread overview | |||||
---|---|---|---|---|---|
|
May 08, 2011 Shouldn't duplicate functions be caught by DMD? | ||||
---|---|---|---|---|
| ||||
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 08, 2011 Re: Shouldn't duplicate functions be caught by DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | 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 Re: Shouldn't duplicate functions be caught by DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 08/05/2011 09:41, bearophile wrote: > 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. <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. |
Copyright © 1999-2021 by the D Language Foundation