Following code minimized from an application unitest using dunit doesn't compile with 2.066.0-b6 (2.065 was ok):
FooTest.d(30): Error: first argument is not a symbol
FooTest.d(36): Error: template instance FooTest.FooTest.UnitTest!()._annotations!(FooTest, Ignore, "Node", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory") error instantiating
FooTest.d(32): instantiated from here: _annotations!(FooTest, Ignore, "_annotations", "Node", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory")
FooTest.d(16): instantiated from here: _annotations!(FooTest, Ignore, "__ctor", "_annotations", "Node", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory")
===================================
import std.typetuple;
class Document {
alias NodeImpl* Node;
struct NodeImpl
{
}
}
template UnitTest()
{
this()
{
alias TypeTuple!(__traits(allMembers, typeof(this))) allMembers;
_annotations!(typeof(this), Ignore, allMembers).dup;
}
template _annotations(T, attribute, names...)
{
static if (names.length == 0)
{
immutable(string[]) _annotations = [];
}
else
{
static if (__traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()")))
{
alias TypeTuple!(__traits(getMember, T, names[0])) member;
TypeTuple!(__traits(getAttributes, member)) attributes;
immutable(string[]) _annotations = _annotations!(T, attribute, names[1 .. $]);
}
else
{
immutable(string[]) _annotations = _annotations!(T, attribute, names[1 .. $]);
}
}
}
}
struct Ignore
{
}
class FooTest
{
mixin UnitTest;
alias Node = Document.Node;
}
====================================================================
Comment #1 by k.hara.pg — 2014-07-29T15:23:21Z
In 2.066, uniform constructor syntax T() is supported for all scalar type T.
auto n = int();
auto x = float(3.14);
alias P = void*;
auto p = P(&n);
By the feature, the line
static if (__traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()")))
is changed to be evaluated to true when names[0] == "Node".
(new FooTest()).Node() == Node() (Node == Document.Node == NodeImpl*)
Comment #2 by bugzilla — 2014-07-31T02:45:01Z
Evidently this new feature is breaking code. Sigh.