On 06/11/12 07:09, Rob T wrote:
On Friday, 2 November 2012 at 22:33:37 UTC, Rob T wrote:
I discovered it fails to compile when inside a function with "auto" as
the return type.
auto test()
{
throw new Exception( mixin(__FUNCTION) );
return 0;
}
Error: forward reference to test
but this works
int test()
{
throw new Exception( mixin(__FUNCTION) );
return 0;
}
So we're kinda sunk for inclusion in phobos unless this error can be
resolved.
I'll try the enum idea to see if that works.
--rt
An update on this problem. I found out that the error when using auto as
return type has nothing to do with the mixin. The compiler error
persists when you take mixin out and put in the __traits( ... ) code
directly.
Does anyone else think that this is a compiler bug? If it is a bug then
I'll report it in the bug tracker.
--rt
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.