[Issue 9905] New: Template parameters used in argument delegate's arguments not inferred even if used and inferred previously in the function call
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 8 15:12:16 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9905
Summary: Template parameters used in argument delegate's
arguments not inferred even if used and inferred
previously in the function call
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: GenericNPC at gmail.com
CC: k.hara.pg at gmail.com
--- Comment #0 from IdanArye <GenericNPC at gmail.com> 2013-04-08 15:12:15 PDT ---
A simple example:
void foo(T)(T a, void delegate(T) dlg){}
Calling it like this works:
foo(1,(int x){});
foo!int(1,(x){});
But trying to call it like this:
foo(1,(x){});
Produces:
main.d(8): Error: template main.foo does not match any function template
declaration. Candidates are:
main.d(5): main.foo(T)(T a, void delegate(T) dlg)
main.d(8): Error: template main.foo(T)(T a, void delegate(T) dlg) cannot
deduce template function from argument types !()(int,void)
It seems that after reading the first argument `1` into `a`, the compiler knows
that `T` is `int`, but when it starts reading the second argument `(x){}` into
`dlg`, the compiler forgets that `T` is `int` and treats it as an unknown
template parameter.
Might be related to Issue 9393
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list