This is a problem with a return of inner defined struct, I don't know if this specific case is already present in Bugzilla. I think others are already present. DMD 2.048 compiles and runs this code with no errors: static struct Bar(T) { void spam() { foo(1); } } Bar!T foo(T)(T) { return Bar!T(); } void main() { foo(1); } But if I pull the Bar struct inside foo(), using auto as return type: auto foo(T)(T) { static struct Bar(T) { void spam() { foo(1); } } return Bar!T(); } void main() { foo(1); } I receive at compile-time: test.d(4): Error: forward reference to inferred return type of function call foo(1) test.d(7): Error: template instance test.foo!(int).foo.Bar!(int) error instantiating test.d(10): instantiated from here: foo!(int)
https://github.com/D-Programming-Language/dmd/pull/3365
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c23044e9d279b2e8d38909b15419e51843767c75 fix Issue 4757 - A forward reference error with return of inner defined struct https://github.com/D-Programming-Language/dmd/commit/c015f0d2cd2aa24798838c583e2842e696c47466 Merge pull request #3365 from CyberShadow/fix4757 fix Issue 4757 - A forward reference error with return of inner defined struct