Comment #0 by bearophile_hugs — 2010-02-18T12:52:18Z
import std.stdio: writeln;
void main() {
double sqr(double x) { return x * x; }
writeln(typeid(typeof(&sqr)));
pure double psqr(double x) { return x * x; }
writeln(typeid(typeof(&psqr)));
}
It prints:
double delegate()
double delegate()
Instead of:
double delegate(double x)
pure double delegate(double x)
Comment #1 by bearophile_hugs — 2010-02-18T12:53:26Z
> Instead of:
> double delegate(double x)
> pure double delegate(double x)
Sorry, I meant:
Instead of:
double delegate(double)
pure double delegate(double)
Comment #2 by bearophile_hugs — 2010-06-07T14:45:46Z
Another example, with functions too:
import std.stdio: writeln;
int foo(float x) { return 0; }
void main() {
writeln(typeid(typeof(foo))); // int()
int bar(float x) { return 0; }
writeln(typeid(typeof(bar))); // int()
int delegate(float) baz = (float x) { return 0; };
writeln(typeid(typeof(baz))); // int delegate()
}
Comment #3 by nfxjfg — 2010-06-07T20:18:07Z
This has the same cause as #3086.
If you don't think it deserves to be marked as duplicate, undo it.
(But I think it's a good idea to keep bug reports caused by the same thing at minimum.)
Comment #4 by nfxjfg — 2010-06-07T20:20:13Z
*** This issue has been marked as a duplicate of issue 3086 ***
Comment #5 by bugzilla — 2011-04-05T20:39:25Z
3086 doesn't fix it. It could be fixed by having toString() demangle the deco.
Comment #6 by andrej.mitrovich — 2013-02-01T17:02:44Z
(In reply to comment #5)
> 3086 doesn't fix it. It could be fixed by having toString() demangle the deco.
Well it returns 'FfZi' for this function:
int foo(float x) { return 0; }
But std.demangle doesn't decode it.
Comment #7 by razvan.nitu1305 — 2017-09-05T10:49:49Z
This is a dmd bug, not a phobos one. Changing the component to dmd.
Comment #8 by dlang-bot — 2019-08-27T06:08:12Z
@RazvanN7 created dlang/druntime pull request #2764 "Fix Issue 3831 - writeln of a delegate typeid" fixing this issue:
- Fix Issue 3831 - writeln of a delegate typeid
https://github.com/dlang/druntime/pull/2764
Comment #9 by dlang-bot — 2019-08-27T13:08:19Z
dlang/druntime pull request #2764 "Fix Issue 3831 - writeln of a delegate typeid" was merged into master:
- d593facd75aefb89170ea6fe922d7c35b1b34542 by RazvanN7:
Fix Issue 3831 - writeln of a delegate typeid
https://github.com/dlang/druntime/pull/2764