[Issue 16528] New: @safe inference does not work for mutually recursive functions

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 23 08:29:16 PDT 2016


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 at puremagic.com
          Reporter: andrei at 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);
}

--


More information about the Digitalmars-d-bugs mailing list