Bug 10591 – Error: only one main allowed doesn't show location of conflicting main symbols

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-09T20:19:00Z
Last change time
2016-10-01T11:48:27Z
Assigned to
nobody
Creator
thelastmammoth

Comments

Comment #0 by thelastmammoth — 2013-07-09T20:19:02Z
---a.d void main(){} --- ---b.d void main(){} --- ---main.d import a,b; --- rdmd main.d (or dmd main.d a.d b.d) =>b.d(1): Error: only one main allowed the error message should show: b.d(1): Error: only one main allowed (previously defined in a.d(1)) In more complex cases (with auto generated code or mixins etc), it can be hard to trace down location of such main symbols, so compiler should show that.
Comment #1 by andrej.mitrovich — 2013-07-09T20:24:22Z
I guess I should have been more persistent about error messages: https://github.com/D-Programming-Language/dmd/pull/1753#discussion_r3403264
Comment #2 by thelastmammoth — 2013-07-10T12:06:22Z
you wrote there: >> But maybe it doesn't matter all that much, the user can do a global search to find the offending main function. That can be hard in practice (in my cases I auto-generate my main functions to add instrumentation code; or main could be in object file where we don't have source code etc). And user shouldn't have to do such global search when compiler knows this information.
Comment #3 by john.loughran.colvin — 2016-08-18T10:34:44Z
Just ran in to this, I'm actually struggling to find the offending main function in a large codebase (could be in some dependency that's wrongly configured to compile in execultable mode instead of library). Grep doesn't cut it, the compiler should tell me.
Comment #4 by github-bugzilla — 2016-08-21T08:14:33Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/03a8430a1025475d9020bd2e21fa0de6491b3f57 Merge pull request #6069 from John-Colvin/duplicatemainerror Fix issue 10591 - Error: only one main allowed doesn't show location of conflicting main symbols
Comment #5 by github-bugzilla — 2016-10-01T11:48:27Z
Commit pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/03a8430a1025475d9020bd2e21fa0de6491b3f57 Merge pull request #6069 from John-Colvin/duplicatemainerror