On 06.08.2016 07:56, ag0aep6g wrote:

Add parentheses to the typeof one and it fails as expected:

    static assert(is(typeof(a.foo()))); /* fails */

Can also do the function literal thing you did in the __traits one:

    static assert(is(typeof(() { a.foo; }))); /* fails */

You can, but don't.

class A {
    int foo() { return 1; }
}

void main() {
    auto a = new A;
    static void gotcha(){
        // This passes:
        static assert(is(typeof((){a.foo;})));
        // This doesn't:
        static assert(__traits(compiles,(){a.foo;}));
    }
}

Reply via email to