digitalmars.D.bugs - [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 puremagic.com (37/37) Apr 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9905
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 puremagic.com ReportedBy: GenericNPC gmail.com CC: k.hara.pg gmail.com 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: -------
Apr 08 2013