[Issue 16265] New: unittest imports should not be counted as dependencies for static ctors
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jul 11 06:27:43 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16265
Issue ID: 16265
Summary: unittest imports should not be counted as dependencies
for static ctors
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at yahoo.com
A module like this:
shared static this() {...}
unittest {
import other; // other imports this module, and contains static ctors
other.foo();
}
Should not be considered a cycle. The shared ctor cannot possibly call the unit
test code, so there is no leaking of the import.
The only place static ctors can exist inside a unittest is in a local class or
struct. We can easily detect this and allow the dependency based on that.
This allows things like examples and other useful mechanisms, to be located in
the right module, without causing frivolous cycles. I've had to fix several
such "cycles" in phobos recently.
The easiest way to fix this is to simply not emit the dependency into the
module info in such a case.
--
More information about the Digitalmars-d-bugs
mailing list