Bug 2438 – Cannot get types of delegate properties
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-11-01T04:36:00Z
Last change time
2014-08-10T12:54:45Z
Keywords
rejects-valid
Assigned to
nobody
Creator
samukha
Comments
Comment #0 by samukha — 2008-11-01T04:36:42Z
alias void delegate() Dg;
alias typeof(Dg.ptr) Ptr;
alias typeof(Dg.funcptr) Funcptr;
----
test.d(13): Error: argument void* to typeof is not an expression
test.d(13): Error: argument void* to typeof is not an expression
test.d(14): Error: void delegate() is not an lvalue
Worked around by defining an intermediate delegate instance:
alias void delegate() Dg;
Dg dummy;
alias typeof(dummy.ptr) Ptr;
alias typeof(dummy.funcptr) Funcptr;
Comment #1 by jarrett.billingsley — 2008-11-01T09:19:29Z
Not that I don't think it's a bug, but - what the heck? I honestly can't tell what Dg.ptr is. The compiler doesn't accept it as a type, but it also doesn't accept it as an expression. Dg.ptr.stringof gives "void*", as if it's a type. I'm kind of surprised that you can access it at all.
Also, another workaround is to use typeof(Dg.init.ptr/funcptr).
Comment #2 by samukha — 2008-11-01T10:47:58Z
typeof(Dg.init.funcptr) fails:
Error: null is not an lvalue
BTW, typeof((int[]).ptr) works as expected
Comment #3 by github-bugzilla — 2014-08-10T12:54:35Z