http://d.puremagic.com/issues/show_bug.cgi?id=7483
--- Comment #2 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 2012-02-12 02:48:48 PST --- (In reply to comment #1) > Your example function is an infinite recursion. Both for determining the > return > type as well as hypothetically at runtime. I've rushed too quickly and posted a silly example. My use-case was code like this: auto foo(bool check) { if (check) { check = false; return foo(check); } else { return 1; } } I don't know whether this would be too difficult for the compiler to figure out on its own. But the basic idea is: if there's at least one known type for a return expression then the function's return type becomes that type and there's no longer a forward reference error. If there are any other return expressions they all must have the same type (just like usual functions). E.g. this would be legal: auto foo(int state) { if (state == 1) { state++; return foo(state); } else if (state == 2) { return tuple(0, 0); } else { return tuple(0, 0); } } The return type is std.typecons.Tuple!(int,int).Tuple for the last two return expressions, the first return is not taken into account since it's a recursive call, and all other return expression types match. This one would be illegal since all the return types don't match: auto foo(int state) { if (state == 1) { state++; return foo(state); } else if (state == 2) { return tuple(0, 0); } else { return tuple(0, 0, 0); } } The OP sample would still be invalid since you can't figure out the return type at all in that case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------