www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16265] New: unittest imports should not be counted as


          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 puremagic.com
          Reporter: schveiguy yahoo.com

A module like this:

shared static this() {...}

unittest {
import other; // other imports this module, and contains static ctors

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.

Jul 11 2016