[Issue 7713] lambda inference doesn't work on template function argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 15 22:49:39 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7713



--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2012-03-15 22:49:51 PDT ---
(In reply to comment #2)
> Question: Would this also allow:
> 
> void foo(T)(T t, bool delegate(T) dg)
> {
> }
> 
> void main()
> {
>     foo(1, (i) { return true; });
> }
> 
> or is it limited to the return type of the delegate (or is this completely
> unrelated to this bug?)?

This is unrelated bug, and your sample is NEVER compiled.
Because each parameter type inference runs in *parallel*.

[1] T                is deduced from argument   1
 -> T is deduced to int, OK.
[2] bool delegate(T) is deduced from argument   (i) { return true; }
 -> Before template parameter type deduction, the delegate parameter i is
    deduced to T from template function parameter type, but T is not a
    real type.
    Then compiler cannot determine the delegate literal type.
[1] succeeded but [2] failed, so whole IFTI would fail.

The point is [1] and [2] runs in parallel, so they have no dependency.

-- 
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