www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14965] New: Forward reference to inferred return type of

https://issues.dlang.org/show_bug.cgi?id=14965

          Issue ID: 14965
           Summary: Forward reference to inferred return type of function
                    call when using auto return type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: chalucha gmail.com

import std.stdio;
import std.range : chain;

auto test(string a) {
    return test(a, "b");
}

auto test(string a, string b) {
    return chain(a, b);
}

void main() {
    writeln(test(a));
}

Ends with: Error: forward reference to inferred return type of function call
'test'

I know this exact sample is solvable by default parameter but there are cases
where it is not possible.

Workaround is discussed here:
http://forum.dlang.org/post/cyvekwuwskhexribcbbl forum.dlang.org

--
Aug 26 2015