On Tuesday, 5 March 2013 at 07:53:15 UTC, cal wrote:
I'm confused about this:

import std.conv;

void main()
{
    enum s = "`1`.to!int;";
enum c = __traits(compiles, mixin("{auto a = new "~s~";}")); // line 1
    mixin("auto a = "~s~";");
 // line 2
}

This does not compile, giving errors about instantiating std.conv.to!(int).to!(string). If I switch the order of lines 1 and 2 it compiles. Is this a bug or something I don't understand about __traits(compiles)?

You can't test declarations inside of __traits(compiles), only expressions. It's in the docs: http://dlang.org/traits.html#compiles

Reply via email to