[Issue 14694] New: Functions nested within functions need their body in the generated .di file

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 12 13:50:11 PDT 2015


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

          Issue ID: 14694
           Summary: Functions nested within functions need their body in
                    the generated .di file
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrei at erdani.com

Obvious in retrospect. Repro picked from std.array:

inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow
{
    alias U = inout(T);
    static U* max(U* a, U* b) nothrow { return a > b ? a : b; }
    static U* min(U* a, U* b) nothrow { return a < b ? a : b; }

    auto b = max(r1.ptr, r2.ptr);
    auto e = min(r1.ptr + r1.length, r2.ptr + r2.length);
    return b < e ? b[0 .. e - b] : null;
}

After .di generation:

pure nothrow @trusted inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2)
{
        alias U = inout(T);
        static nothrow U* max(U* a, U* b);
        static nothrow U* min(U* a, U* b);
        auto b = max(r1.ptr, r2.ptr);
        auto e = min(r1.ptr + r1.length, r2.ptr + r2.length);
        return b < e ? b[0..e - b] : null;
}

Obviously that's not going to work for more than one reason :o).

--


More information about the Digitalmars-d-bugs mailing list