Thread overview
[Issue 10591] New: Error: only one main allowed doesn't show location of conflicting main symbols
Jul 10, 2013
Andrej Mitrovic
July 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10591

           Summary: Error: only one main allowed doesn't show location of
                    conflicting main symbols
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: thelastmammoth@gmail.com


--- Comment #0 from thelastmammoth@gmail.com 2013-07-09 20:19:02 PDT ---
---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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10591


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-07-09 20:24:22 PDT ---
I guess I should have been more persistent about error messages: https://github.com/D-Programming-Language/dmd/pull/1753#discussion_r3403264

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10591



--- Comment #2 from thelastmammoth@gmail.com 2013-07-10 12:06:22 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------