www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21419] New: Spurious "forward reference to inferred return

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

          Issue ID: 21419
           Summary: Spurious "forward reference to inferred return type of
                    function call" with recursive template functions
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

/////////////////////////// test.d //////////////////////////
auto fun(int x)()
{
    gun();
}

void gun()()
{
    fun!2();
}

unittest
{
//  fun!1(); // Uncomment to fix below instantiation
    fun!2(); // forward reference to inferred return type ...
}
/////////////////////////////////////////////////////////////

Similar to issue 10810. However, there is evidence that this is just a dirty
compiler bug instead of some intrinsic design limitation: explicitly
instantiating the template with a parameter different from the one used in the
recursive call causes the recursive instantiation to succeed (causing "spooky
action at a distance").

--
Nov 23 2020