On 2012-46-06 08:11, Don Clugston <d...@nospam.com> wrote:

It fails because you're asking for the full function name, before its type has been determined. (There's no real return type 'auto', 'auto' just means 'work it out for me').

I don't think this is a bug. Although it might be solvable in this particular example, in general it's a circular dependency.

eg, if you do:

auto foo()
{
    static if (__FUNCTION == "int foo()") { return 'a' }
    return 0;
}
if __FUNCTION is "int foo()" then it will return a char, which means its signature is "char foo()". This is a contradiction.

DMD already does some cycle detection for types, right? I don't remember
the details, but i seem to recall this was made to work a few releases back:

class Foo {
    static if ( is( typeof( Foo.bar ) ) ) {
        void baz() {}
    }
    static if ( true ) {
        int bar() {}
    }
}

The algorithm would probably have to exclude mixins, but I think it could
be made to work for most cases.

--
Simen

Reply via email to