On 4/14/18 4:16 AM, bauss wrote:
I tried to use __traits(compiles) but it always returns false for the
code I'm going to mixin, even though it's valid, that was my initial go
to, so this is really a second attempt on something to give meaningful
error messages when certain mixins don't compile.
Hm.. that seems annoying. I'd guess you'd get simple tests to work,
maybe it's the way you are using __traits(compiles).
If all else fails, back out to the place where you are using it. At some
point, it is a function call. Just wrap that call, and check if it
compiles or not.
e.g.:
static assert(__traits(compiles, theFunction(theItem), "this code won't
compile: " ~ theItem.source);
// if we get here, it will compile
theFunction(theItem);
D can be quite perplexing when you have so much meta in it :)
-Steve