is there some know bugs with traits, type and library?
Lloyd Dupont
ld-REMOVE at galador.net
Fri Jun 24 07:53:16 PDT 2011
I have code like that:
----
module main;
import std.variant;
import std.stdio;
import std.metastrings : Format;
import std.traits;
public mixin template property(T, string name)
{
mixin(Format!("private T _%s;
@property public T %s() { return _%s; }
@property public void %s(T value) { _%s = value; }", name,
name, name, name, name));
}
interface IInter
{
}
class Foo : IInter
{
static this()
{
Compiled!(Foo, "FP");
Compiled!(Foo, "Subfoo");
}
@property public Foo FP() { return new Foo(); }
@property public void FP(Foo f) { }
mixin property!(Foo, "Subfoo");
}
int main(string[] argv)
{
Foo f = new Foo();
__traits(getMember, f, "FP") = new Foo();
return 0;
}
void Compiled(T, string memberName)()
{
T t;
writeln(mixin( "__traits(compiles, t." ~memberName ~" = ("
~typeof(__traits(getMember, T, memberName)).stringof ~").init)" ));
//writeln((__traits(getMember, t, memberName) =
typeof(__traits(getMember, T, memberName)).init).stringof);
}
----
This sample works fine, and print "true" twice!
However in my real program, which span a couple of static library and 1 exe,
it print false if my property are of objet type (as opposed to int, string,
etc...)
i.e. the reflection library seems to think that
mixin( "__traits(compiles, t." ~memberName ~" = ("
~typeof(__traits(getMember, T, memberName)).stringof ~").init)" )
evaluate to false if typeof(__traits(getMember, T, memberName) is a class...
any ideas?
More information about the Digitalmars-d
mailing list