www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17444] New: std.traits.isCallable doesn't recognize struct

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

          Issue ID: 17444
           Summary: std.traits.isCallable doesn't recognize struct member
                    function if return type is 'auto'.
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dario.schiavon gmail.com

import std.traits : isCallable;

struct MyStruct
{
    auto foo() { return MyStruct(); }

    static if (isCallable!foo)
        pragma(msg, "GOOD");
    else
        pragma(msg, "BAD");
}

Prints "GOOD" if foo returns 'MyStruct' instead of 'auto'.
Member function foo is actually usable in both cases.
I'm unsure whether this is a Phobos problem or a compiler problem.
Using DMD32 v2.074.0 or LDC2 v1.1.1 (which is based on DMD v2.071.2).

--
May 27