First off, this bug report is for dmd 1.053, not 1.051; but bugzilla let's me only select up to 1.051.
The following code outputs "what (void())()", which shows that function pointers are matched with is(T T2 : T2*). I think this shouldn't be the case: although technically function pointers really are pointers, D doesn't declare them using the pointer syntax, doesn't allow them to be dereferenced, and they don't point to any type.
If this bug is fixed, functions won't match with is(T T2 : T2*) anymore.
If this is just an anti-feature and not a bug, please mark this bug report as "invalid".
struct X {
void function() foo;
}
void moo(T)() {
static if (is(T T2 : T2*)) {
pragma(msg, "what "~T2.stringof);
}
}
void main() {
X x;
foreach (int index, z; x.tupleof) {
moo!(typeof(z));
}
}
Comment #1 by smjg — 2009-12-26T11:11:08Z
I've always been under the impression that immediate function types aren't meant to exist in D, which would mean that the is expression should fail.
But there does seem to be some confusion over it. And in any case, the stringof does seem wrong.
Comment #2 by smjg — 2010-01-02T16:44:03Z
You stated that it's 1.053 you found it in, but inadvertently set it to 1.054 when the version list was updated.
But I've just found that I'm still on 1.051 and the bug shows in it, so reverting per policy.
Comment #3 by nfxjfg — 2010-01-02T16:51:16Z
I guess the bug exists since the early days of dmd.
Just to clarify it: it also exists in 1.054. (That's why I changed it; sorry for the confusion, won't do again.)
A statement from Walter whether this is an anti-feature or a bug would be nice. (And in general, there are far too many bug reports with unknown status, that remain uncommented.)
Comment #4 by nfxjfg — 2010-01-19T12:30:59Z
PS: as far as is() is concerned, functions should just work like delegates. Any difference should be considered as bug.
Also, if this happens not to be a bug, please mark it as "enhancement", and not as "invalid" (like I said above).
Comment #5 by bugzilla — 2011-04-12T11:15:01Z
void function() foo;
declares foo as a function pointer.
is(T T2 : T2*)
matches a pointer, and sets T2 to whatever is pointed to.
Hence what is printed out is correct. Not a bug.