D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2579 - Template function accepting a delegate with in argument doesn't compile
Summary: Template function accepting a delegate with in argument doesn't compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2009-01-10 21:00 UTC by Sergey Gromov
Modified: 2015-06-09 01:21 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Sergey Gromov 2009-01-10 21:00:59 UTC
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.