[Issue 1373] New: typeof(func).stringof fails when func has parameters.
Reiner Pope
some at address.com
Fri Aug 31 15:52:02 PDT 2007
d-bugmail at 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 at digitalmars.com
> ReportedBy: clugdbug at 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.
More information about the Digitalmars-d-bugs
mailing list