digitalmars.D.bugs - [Issue 1373] New: typeof(func).stringof fails when func has parameters.
- d-bugmail puremagic.com (29/29) Jul 25 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1373
- Reiner Pope (7/43) Aug 31 2007 I think a related issue is
- d-bugmail puremagic.com (12/12) Oct 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1373
- d-bugmail puremagic.com (9/15) Oct 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1373
- d-bugmail puremagic.com (23/23) Apr 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1373
- d-bugmail puremagic.com (13/13) Jul 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=1373
http://d.puremagic.com/issues/show_bug.cgi?id=1373 Summary: typeof(func).stringof fails when func has parameters. Product: D Version: 1.019 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au If func is a function (not a function pointer) with zero arguments, it works correctly (I think). But if it is a function with >0 arguments, then it complains that it cannot evaluate it. Curiously, it generates the correct result, as evidenced by pragma(msg) below, before giving the error. -------------- double func0() { return 0; } int func2(int a, int b) { return 2; } void main() { static assert(typeof(func0).stringof=="(double())()"); // OK pragma(msg, typeof(func2).stringof); // bug.d(8): Error: expected 2 arguments, not 0 // (int(int a, int b))() static assert(typeof(func2).stringof=="(int(int a, int b))()"); } --
Jul 25 2007
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=1373 Summary: typeof(func).stringof fails when func has parameters. Product: D Version: 1.019 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au If func is a function (not a function pointer) with zero arguments, it works correctly (I think). But if it is a function with >0 arguments, then it complains that it cannot evaluate it. Curiously, it generates the correct result, as evidenced by pragma(msg) below, before giving the error. -------------- double func0() { return 0; } int func2(int a, int b) { return 2; } void main() { static assert(typeof(func0).stringof=="(double())()"); // OK pragma(msg, typeof(func2).stringof); // bug.d(8): Error: expected 2 arguments, not 0 // (int(int a, int b))() static assert(typeof(func2).stringof=="(int(int a, int b))()"); }I think a related issue is void func(int) {} const text = func.stringof; which doesn't compile under 2.003, error message: "func_stringof.func(int) does not match parameter types ()". However, it works if the int parameter is removed.
Aug 31 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1373 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com ------- Comment #2 from smjg iname.com 2007-10-21 11:08 ------- Please don't blindly quote the entire message when replying. It's bad enough on any newsgroup, and when it clutters up Bugzilla, it's even worse. This issue is puzzling me. Surely typeof(func0) should be double, since as an expression, func0 is equivalent to func0(). And typeof(func2) probably shouldn't compile. --
Oct 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1373 ------- Comment #3 from clugdbug yahoo.com.au 2007-10-23 10:49 ------- (In reply to comment #2)Please don't blindly quote the entire message when replying. It's bad enough on any newsgroup, and when it clutters up Bugzilla, it's even worse. This issue is puzzling me. Surely typeof(func0) should be double, since as an expression, func0 is equivalent to func0(). And typeof(func2) probably shouldn't compile.Function types _are_ wierd. And not well documented. What is func2 ? It's a symbol of "function type". The only thing you do with it it takes its address. Since in the spec, it's allowable in & UnaryExpression, it must be an expression, but I can't see it listed there. Definitely related to issue #1341. --
Oct 23 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1373 Harry Vennik <htvennik zonnet.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |htvennik zonnet.nl --- Comment #4 from Harry Vennik <htvennik zonnet.nl> 2010-04-26 06:20:08 PDT --- This issue bugged me with DMD 2.043 on Mac. I noticed something peculiar which is demonstrated by this test case: ----- void foo(int i) { } enum string FOO_TYPE = typeof(foo).stringof; pragma(msg, "Type of foo is: " ~ FOO_TYPE); ----- Compiling that will print: ----- stringof_error.d(2): Error: expected 1 function arguments, not 0 Type of foo is: (void(int i))() ----- So actually, the .stringof is correctly evaluated, but still some unnecessary check for function arguments makes the compiler generate an error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1373 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED --- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2011-07-01 22:13:17 PDT --- https://github.com/D-Programming-Language/dmd/commit/28702b21e143807205f6798b000a0c05bb22d5e2 https://github.com/D-Programming-Language/dmd/commit/23bef66be596ab4541fe26a5433f8cdbd92fc4ac -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2011