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: [email protected]
          Reporter: [email protected]

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);
}

--

Reply via email to