[Issue 5933] New: Cannot retrieve the return type of an auto-return member function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 6 02:24:39 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5933

           Summary: Cannot retrieve the return type of an auto-return
                    member function
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: kennytm at gmail.com


--- Comment #0 from kennytm at gmail.com 2011-05-06 02:19:58 PDT ---
Test case:

------------------------------
struct X {
    auto x() {
        return 0; 
    }
}
pragma(msg, typeof(X.init.x));
static assert(is(typeof(&X.init.x) == int delegate()));
------------------------------
()
x.d(7): Error: static assert  (is(typeof(__error) == int delegate())) is false
------------------------------

The expected output is 'int()' and the static assert should pass. The '__error'
comes out because DMD thinks X.init.x is forward-referenced.




This also causes a ICE when using with std.traits.ReturnType:

------------------------------
struct X {
    auto x() {
        return 0; 
    }
}
static if (is(typeof(X.init.x) R == return)) {}
------------------------------
Assertion failed: (type), function AliasDeclaration, file declaration.c, line
376.
Abort trap
------------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list