D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19058 - __traits(getUnitTests) stops working with separate compilation in dmd 2.081.0
Summary: __traits(getUnitTests) stops working with separate compilation in dmd 2.081.0
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-04 20:45 UTC by Atila Neves
Modified: 2018-08-27 04:30 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Atila Neves 2018-07-04 20:45:00 UTC
This is a regression of 16995 caused by:

commit 849155631cba3017566d3160cf15cb40584abf10
Author: Johan Engelen <jbc.engelen@gmail.com>
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 johanengelen 2018-07-05 19:50:03 UTC
Do you have a testcase ?
Comment 2 Atila Neves 2018-07-06 10:30:20 UTC
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/krkinfxikztqvudjopao@forum.dlang.org
Comment 3 Atila Neves 2018-07-06 10:49:42 UTC
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 Martin Nowak 2018-08-22 11:05:34 UTC
Related to issue 14894
Comment 5 github-bugzilla 2018-08-27 04:30:37 UTC
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…