[Issue 12269] Unittest within template struct scope is not executed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 26 18:10:59 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12269



--- Comment #1 from growlercab at gmail.com 2014-02-26 18:10:55 PST ---
After some more testing I have some more information which may help.

Firstly, the problem is also present in DMD 2.064.
(I have no DMD older than this)

Secondly, I found that the unittest within struct scope is run only if S is
instantiated in a module scope unit test.

For example the following incorrectly compiles and executes without an error:

$ rdmd --main -unittest -debug utbug.d
---
// utbug.d
struct S(T) {
    unittest {
        BUGME("should not compile"); // <<-- should break the build
    }
}

unittest {
}
----

But instantiating S!int() in the module scope unit test works as expected:


$ rdmd --main -unittest -debug utbug.d
utbug.d(5): Error: undefined identifier BUGME
utbug.d(9): Error: template instance utbug.S!int error instantiating

---
// utbug.d
struct S(T) {
    unittest {
        BUGME("should not compile"); // <<-- Should break the build
    }
}

unittest {
    auto s = S!int();
}
----

Thanks,
ed

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list