www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15794] New: Lambda mangled differently after being passed as

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

          Issue ID: 15794
           Summary: Lambda mangled differently after being passed as
                    template argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

The following program fails to link because the lambda on line 26 is mangled
differently in functions fun and gun:


struct Foo {
    static void fun(Holder)() {
        pragma(msg, "Mangled name in fun:");
        pragma(msg, Holder.fn.mangleof);
        pragma(msg, "");
        int i = Holder.fn();
    }
}

struct Holder(alias Fn) {
    alias fn = Fn;
}

void gun(alias fn, U...)() {
    Foo.fun!(Holder!fn)();

    pragma(msg, "Mangled name in gun:");
    pragma(msg, fn.mangleof);
    pragma(msg, "");
    static if (U.length > 0) {
        return gun!U;
    }
}

unittest {
    gun!(() => 0)(); // Line 26
}

--
Mar 13 2016