On Monday, 13 August 2012 at 19:09:04 UTC, Minas Mina wrote:
Is it a bug with auto or something else?
It's not really a bug. You're using insert before its return type has been inferred. Hence, it says "forward reference to inferred return type".
However, in this case, it should be possible to infer the return type because they type of root is known. Maybe an enhancement request?
In any case, the solution, as you've found, is to explicitly define the return type if you're going to be using it recursively.