On Wednesday, 26 October 2016 at 16:12:26 UTC, Timothee Cour wrote:
It should just be implied by -unittest!

+1


On Wed, Oct 26, 2016 at 7:49 AM, Nick Sabalausky via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

On 10/26/2016 09:25 AM, Adam D. Ruppe wrote:

On Wednesday, 26 October 2016 at 08:15:44 UTC, Basile B. wrote:

What would be possible is a "-fdmain" switch (force dummy main).


It should just be implied by -unittest!

The only cast I'd be worried about is an explicit version(unittest) main() {}... then maybe the user wanted something special. And even then, meh, 99% of those cases are just fixing the broken default anyway.

Otherwise, let's make the default sane.


+1

It looks fairly simple to do in dmd, like this (with breakage in case the user-defined main() did something useful):

1. deactivate the main functionDeclaration un funcs.d

....
final bool isMain()
{
return ident == Id.main && linkage != LINKc && !isMember() && !isNested()
    && !global.params.useUnitTests;
}
...

2. forces -main in params.d:

...
else if (strcmp(p + 1, "unittest") == 0)
{
    global.params.useUnitTests = true;
    global.params.addMain = true;
}
...

I see no reason to discuss much about this. People that are pro should just agree on how this should be done and someone makes a PR.

Maybe the little issue would be with LDMD2 and GDMD. Since these programs are just bridges they cannot do point 1, and LDC2 and GDC would have to follow this behavior.

Reply via email to