digitalmars.D.bugs - [Issue 966] New: is(H==function) fails if H is a function type
- d-bugmail puremagic.com (26/26) Feb 15 2007 http://d.puremagic.com/issues/show_bug.cgi?id=966
- d-bugmail puremagic.com (6/6) Mar 29 2007 http://d.puremagic.com/issues/show_bug.cgi?id=966
- d-bugmail puremagic.com (17/17) Aug 12 2007 http://d.puremagic.com/issues/show_bug.cgi?id=966
http://d.puremagic.com/issues/show_bug.cgi?id=966
Summary: is(H==function) fails if H is a function type
Product: D
Version: 1.005
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: elmar zandere.de
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.
--
Feb 15 2007
http://d.puremagic.com/issues/show_bug.cgi?id=966 Added to DStress as http://dstress.kuehne.cn/compile/i/is_17_A.d http://dstress.kuehne.cn/compile/i/is_17_B.d --
Mar 29 2007
http://d.puremagic.com/issues/show_bug.cgi?id=966
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
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.
--
Aug 12 2007









d-bugmail puremagic.com 