Thread overview
[Issue 18868] Separate compilation generates two static this functions, runs it twice
May 17, 2018
Shachar Shemesh
Jun 04, 2018
FeepingCreature
Jul 04, 2018
Atila Neves
Jul 04, 2018
Atila Neves
May 16, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
May 16, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

--- Comment #1 from johanengelen@weka.io ---
https://github.com/dlang/dmd/pull/8255

--
May 17, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

Shachar Shemesh <shachar@weka.io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shachar@weka.io

--
May 19, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

--- Comment #2 from johanengelen@weka.io ---
Extra testcase that must be added and considered (currently works):
```
static foreach(s; ["666", "777"]) {
    mixin(genCtor(s));
}

int i;

string genCtor(string a)
{
    return "static this() { i += " ~ a ~ "; }";
}

void main()
{
    assert(i == 0 + 666 + 777);
}
```

--
May 28, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

--- Comment #3 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/849155631cba3017566d3160cf15cb40584abf10 fix Issue 18868 - nondeterministic static ctor/dtor

Instead of using a counter to create unique static ctor and dtor function
identifiers, use the deterministic line+column location that is also used for
unittests.
The further disambiguate mixin instantiations on the exact same location, use a
local counter.

https://github.com/dlang/dmd/commit/cf19b78d47572e1c6d1a79687ea592b051552e93 Merge pull request #8255 from JohanEngelen/fix18868

fix Issue 18868 - nondeterministic static ctor/dtor
merged-on-behalf-of: Jacob Carlborg <jacob-carlborg@users.noreply.github.com>

--
May 28, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

github-bugzilla@puremagic.com changed:

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

--
June 04, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

FeepingCreature <default_357-line@yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |default_357-line@yahoo.de

--- Comment #4 from FeepingCreature <default_357-line@yahoo.de> ---
This also fixes this issue:

static foreach (entry; ["foo", "bar", "baz"])
{
  unittest
  {
    writeln(entry);
  }
}

foo
foo
foo

which happened because all three unittest blocks had the same identifier, based on line number.

--
July 04, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

Atila Neves <atila.neves@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |atila.neves@gmail.com

--- Comment #5 from Atila Neves <atila.neves@gmail.com> ---
The fix for this issue introduces a regression and breaks usage of __traits(getUnitTests) and separate compilation. Issue here:

https://issues.dlang.org/show_bug.cgi?id=19058

--
July 04, 2018
https://issues.dlang.org/show_bug.cgi?id=18868

--- Comment #6 from Atila Neves <atila.neves@gmail.com> ---
I forgot to mention that the issue here is the same issue as before with the unittest names - counters can't and won't work, because the number will vary depending on how the compiler is invoked.

--