Bug 19058 – __traits(getUnitTests) stops working with separate compilation in dmd 2.081.0

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-07-04T20:45:00Z
Last change time
2018-08-27T04:30:38Z
Assigned to
No Owner
Creator
Atila Neves
See also
https://issues.dlang.org/show_bug.cgi?id=14894

Comments

Comment #0 by atila.neves — 2018-07-04T20:45:00Z
This is a regression of 16995 caused by: commit 849155631cba3017566d3160cf15cb40584abf10 Author: Johan Engelen <[email protected]> Date: Thu May 17 00:25:56 2018 +0200 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. The reason the existing test for 16995 didn't break is because it only uses one module with unittests, and there must be two different modules with unittests on the same line:column to trigger the regression.
Comment #1 by johanengelen — 2018-07-05T19:50:03Z
Do you have a testcase ?
Comment #2 by atila.neves — 2018-07-06T10:30:20Z
Just compile two files separately with a unittest on the same line and column and have a third import the two and use __traits(getUnitTests). My failing test case is adding another imported module to the existing test at test/runnable/issue16995.d. Also see discussion here at the forum: https://forum.dlang.org/post/[email protected]
Comment #3 by atila.neves — 2018-07-06T10:49:42Z
I've taken a look at the code (I was trying to fix this). As mentioned before, counters can never work. The solution will have to go through using the absolute path of the location since the module doesn't "exist" until semantic. This of course is redundant with respect to symbols colliding, because they won't - they'll get mangled according to their modules. I'd rather only see adding the absolute file path if there are any collisions _and_ the identifiers are in the same module/filepath.
Comment #4 by code — 2018-08-22T11:05:34Z
Related to issue 14894
Comment #5 by github-bugzilla — 2018-08-27T04:30:37Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3a686c04cd777d89cf9343ab39dacd600934ffcb Fix issue 19058 - __traits(getUnitTests) works again with separate compilation https://github.com/dlang/dmd/commit/758c5ac13c1687ff5c8722eeb7bce86eb7f1c3b5 Merge pull request #8542 from atilaneves/fix-traits-get-unittest Fix issue 19058 - __traits(getUnitTests) works again with separate co…