Bug 9905 – Template parameters used in argument delegate's arguments not inferred even if used and inferred previously in the function call

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-08T15:12:15Z
Last change time
2024-12-13T18:05:57Z
Assigned to
No Owner
Creator
IdanArye
Moved to GitHub: dmd#18559 →

Comments

Comment #0 by GenericNPC — 2013-04-08T15:12:15Z
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
Comment #1 by robert.schadek — 2024-12-13T18:05:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18559 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB