Bug 2579 – Template function accepting a delegate with in argument doesn't compile

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-01-10T21:00:00Z
Last change time
2015-06-09T01:21:01Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
snake.scaly

Comments

Comment #0 by snake.scaly — 2009-01-10T21:00:59Z
The following code: void foo(T)(T delegate(in Object) dlg) { } void bar() { foo( (in Object) { return 15; } ); } does not compile: > dmd -c bug_template_in.d bug_template_in.d(7): template bug_template_in.foo(T) does not match any function template declaration bug_template_in.d(7): template bug_template_in.foo(T) cannot deduce template function from argument types !()(int delegate(const(Object) _param_0)) Replacing both instances of 'in Object' with 'const(Object)' makes the code compile. I think these two forms are equivalent and should both compile.
Comment #1 by k.hara.pg — 2011-07-14T04:25:09Z
Comment #2 by bugzilla — 2011-08-24T17:29:57Z