Bug 966 – is(H==function) fails if H is a function type

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-02-15T05:12:00Z
Last change time
2014-02-16T15:21:40Z
Assigned to
bugzilla
Creator
elmar

Comments

Comment #0 by elmar — 2007-02-15T05:12:44Z
The following code fails with an assertion: bool isfun(H)( H h){ static if (is( H == function )) return true; else return false; } void fun( int i ) {} void main() { assert( isfun( &fun ) ); // should not } BTW: If H is a delegate type, then is(H==delegate) works fine in the corresponding code.
Comment #1 by thomas-dloop — 2007-03-29T14:31:13Z
Comment #2 by bugzilla — 2007-08-12T22:10:36Z
That's because &fun is not a function type, it's a pointer to a function. Rewrite the template as: bool isfun(H)( H h){ static if (is( H F == F*) && is(F == function )) return true; else return false; } and it will work.