Thread overview
[Issue 11008] Allow -main switch even if user-defined main function exists
Mar 31, 2021
ZombineDev
Mar 31, 2021
ZombineDev
May 01, 2021
John Hall
Sep 08, 2021
Dlang Bot
Sep 08, 2021
Dlang Bot
March 31, 2021
https://issues.dlang.org/show_bug.cgi?id=11008

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |petar.p.kirov@gmail.com
         Resolution|WONTFIX                     |---

--- Comment #6 from ZombineDev <petar.p.kirov@gmail.com> ---
I'm reopening, since it is useful to have the `-main` switch replace the user-defined function given that the default druntime behavior is to not run `main()` after executing unit tests, since dmd 2.090 - https://dlang.org/changelog/2.090.0.html#unittest-default | https://run.dlang.io/is/GzX7qt

Currently, running `dub test --single` fails if there's a user-defined main: https://github.com/dlang/dub/issues/2122, because of this behavior.

--
March 31, 2021
https://issues.dlang.org/show_bug.cgi?id=11008

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid

--- Comment #7 from ZombineDev <petar.p.kirov@gmail.com> ---
Also, if it is deemed that this would be a breaking change, than I suggest we go with Rainer's suggestion for `-emptymain`.

--
May 01, 2021
https://issues.dlang.org/show_bug.cgi?id=11008

John Hall <john.michael.hall@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.michael.hall@gmail.com

--- Comment #8 from John Hall <john.michael.hall@gmail.com> ---
@ZombieDev As a heads up, following [1], the following code in run.dlang.org [2] produces the only one main error due to relying on dub test --single.

```d
/+dub.sdl:
dependency "mir-algorithm" version="*"
+/

import core.stdc.stdio;

unittest
{
    printf("From unittest\n");
}

void main()
{
    printf("From main\n");
}
```

[1] https://github.com/dlang-tour/core-exec/pull/56
[2] https://run.dlang.io/is/0PlIZU

--
September 08, 2021
https://issues.dlang.org/show_bug.cgi?id=11008

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #13057 "Fix issue 11008 - Allow -main switch even if user-defined main function exists" fixing this issue:

- fix issue 11008 - Allow -main switch even if user-defined main function exists

https://github.com/dlang/dmd/pull/13057

--
September 08, 2021
https://issues.dlang.org/show_bug.cgi?id=11008

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #13057 "Fix issue 11008 - Allow -main switch even if user-defined main function exists" was merged into master:

- c4fa7709ee2bc93bbf071335bfb7027ea3eaf527 by dkorpel:
  fix issue 11008 - Allow -main switch even if user-defined main function
exists

https://github.com/dlang/dmd/pull/13057

--