D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3464 - is( void function() == function) is false
Summary: is( void function() == function) is false
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-01 15:21 UTC by David Simcha
Modified: 2015-06-09 01:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2009-11-01 15:21:27 UTC
pragma(msg, is( void delegate() == delegate).stringof);  // true
pragma(msg, is( void function() == function).stringof);  // false
Comment 1 Lars T. Kyllingstad 2009-11-02 00:00:05 UTC
This is apparently intentional. I recently brought up the same issue on the NG:

http://www.digitalmars.com/d/archives/digitalmars/D/The_bizarre_world_of_typeof_99461.html#N99486

Quoting Don:
"real function()" is a *function pointer*, but is(xxx == function) tests to see if xxx is a *function*, not a *function pointer*.
Comment 2 David Simcha 2009-11-09 06:32:47 UTC
So what is the proper way to test if something is a function pointer then?  It seems horribly inconsistent with delegates.
Comment 3 Max Samukha 2009-11-09 07:14:01 UTC
One way to test: is(typeof(*T.init) == function)
Comment 4 David Simcha 2010-08-15 21:23:01 UTC
I'll mark this invalid, since the language lawyers (IANALL) say it is, and the better solution now that it exists is std.traits.isFunctionPointer.