www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16528] New: safe inference does not work for mutually

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

          Issue ID: 16528
           Summary:  safe inference does not work for mutually recursive
                    functions
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Consider:

void fun1(T)(T value)
{
    if (value) fun2(value - 1);
}

void fun2(T)(T value)
{
    if (value) fun1(value - 1);
}

 safe void main()
{
    fun1(4);
}

This fails to compile although obviously the functions are safe. I'm looking
for a reasonable workaround for the topN work. This doesn't work either:

void fun1(T)(T value)
{
    if (value) fun2(value - 1);
}

void fun2(T)(T value)
{
    if (value) ()  trusted { fun1(value - 1); }();
}

 safe void main()
{
    fun1(4);
}

--
Sep 23 2016