[Issue 16265] unittest imports should not be counted as dependencies for static ctors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 12 21:32:51 UTC 2017


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

--- Comment #6 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Mike Franklin from comment #5)
> I think it would help to have an example that someone could quickly cut and
> paste into their development environment to reproduce and illustrate the
> problem.


Of course. It's going to be a toy example, but things like documented unit
tests cause these kinds of problems, especially when you have so many modules
that you need stuff from in order to run a complete program.

mod1.d:
module mod1;

immutable int val;

shared static this()
{
   val = 2;
}

size_t bar(size_t x) { return x + 1; }

unittest
{
   import mod2;
   assert("abc".foo.bar == 7);
}

mod2.d:
module mod2;

import mod1;

immutable int multiplier;

shared static this()
{
   multiplier = val;   
}

size_t foo(string s) { return s.length * multiplier; }

--


More information about the Digitalmars-d-bugs mailing list