[Issue 19829] New: __traits(isSame) returns true for some non-local delegate lambdas even when they are different

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 26 08:34:14 UTC 2019


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

          Issue ID: 19829
           Summary: __traits(isSame) returns true for some non-local
                    delegate lambdas even when they are different
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: simen.kjaras at gmail.com

>From issue 19828:

import std.stdio : writeln;

unittest {
    int[] arr = [0, 1];

    // Different
    writeln(__traits(isSame, i => arr[i], a => a) ? "Same" : "Different");

    // Same
    test!(i => arr[i], a => a);

    // Different
    test!(i => arr[i], a => a * 4);
}

auto test(alias map1, alias map2)() {
    writeln(__traits(isSame, map1, map2) ? "Same" : "Different");
}

--


More information about the Digitalmars-d-bugs mailing list