[Issue 14210] invalid merging of template instances

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Feb 20 19:33:31 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14210

--- Comment #6 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
(In reply to Kenji Hara from comment #4)
> (In reply to Ketmar Dark from comment #3)
> > this is CTFE wrapper generator, and with merging like now *each* registered
> > delegate with the same parameter types will get the same default values.
> > this kills the whole CTFE wrapper generation idea.
> 
> Unfortunately the code does not work as you expected. Default arguments
> won't be encoded in type, so you cannot capture them via type.
> 
> Instead of that, you need to handle a function symbol.
> 
> void foo(alias f)()
> {
>     import std.traits;
>     pragma(msg, ParameterDefaultValueTuple!f);  // directly give a function
> symbol
> }
> void main()
> {
>     foo!((int a=40) => a+2); // tuple(40)
>     foo!((int a) => a+2);    // (void)
> }

yep, that was exactly the thing i wanted to avoid… i wanted to use `eng["func"]
= (int a=40) => a+2;` instead of `eng["func"] = buildWrapper!((int a=40) =>
a+2);`.

i was tricked by the fact that `typeof(dg)` knows about default args (hence the
hack with `ParameterDefaultValueTuple!dg`), and i was sure that different
default values means "different declared types" for dg, with "same actual
types" (or something like that, i don't know how to word it right).

and your patch broke even that hack. (sobs)

ah, well, i guess i can't get everything i want. at least i found a bug.

thank you.

--


More information about the Digitalmars-d-bugs mailing list