Comment #0 by bearophile_hugs — 2010-08-19T06:57:39Z
This is a wrong D2 program:
int x = 1;
int x = 1;
void main() {}
dmd 2.048 prints a good enough error message:
test.d(2): Error: variable test.x conflicts with variable test.x at test.d(1)
This is another wrong D2 program:
void foo() {}
void foo() {}
void main() {}
But here dmd 2.048 on Windows shows a link error:
OPTLINK (R) for Win32 Release 8.00.2
Copyright (C) Digital Mars 1989-2009 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test) Offset 00151H Record Type 00C3
Error 1: Previous Definition Different : _D4test3fooFZv
In my opinion here it's better for dmd to spot the function foo() duplication and give a cleaner error message, something like:
test.d(2): Error: function test.foo() has the same signature as the function test.foo() at test.d(1)
This bug may happen if a function is duplicated, or if the overloading is done in a wrong way.
Comment #1 by bearophile_hugs — 2010-10-14T14:19:01Z
This shows a related problem:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=22302
> And a note: had forgotten to add an empty main(), just for compiling:
> the linker produced a rather big amount of error text without any hint
> to the actual issue. Maybe dmd could cope with that before calling gcc?
I agree, it's better if DMD gives a nice and clean error message when the main() is missing.
Comment #2 by yebblies — 2011-06-10T09:15:19Z
*** This issue has been marked as a duplicate of issue 1003 ***