[Issue 14965] New: Forward reference to inferred return type of function call when using auto return type

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 26 12:20:08 PDT 2015


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 at puremagic.com
          Reporter: chalucha at 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

--


More information about the Digitalmars-d-bugs mailing list