Bug 5933 – Cannot retrieve the return type of an auto-return member function
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-06T02:19:00Z
Last change time
2013-01-24T21:08:19Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
kennytm
Comments
Comment #0 by kennytm — 2011-05-06T02:19:58Z
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
------------------------------