[Issue 7585] functions in templates inferred as delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 5 17:19:37 PST 2013


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



--- Comment #14 from Kenji Hara <k.hara.pg at gmail.com> 2013-02-05 17:19:33 PST ---
(In reply to comment #10)
> What's the state of this? OP sample works, but in Kenji's Comment #1 sample the
> line which fails is:
> 
> Callback cb3 = &Wrap!(f3);      // NG

The sample in comment#1 was shown old broken compiler behavior.

>    Callback cb1 = &Wrap!(f1);      // OK
>    Callback cb2 = &Wrap!(f2);      // OK

The Wrap function inside Wrap template is declared with extern(C). So it cannot
have any hidden context pointer. And, calling f1 or f2 will not need such extra
pointer, then Wrap!(f1) and Wrap!(f2) will succeed to compile.

>    Callback cb3 = &Wrap!(f3);      // NG

f3 is a nested function. So the Wrap function should get a hidden context to
main function, but it is impossible. Then the instantiation Wrap!(f3) will
fail. 

>    Callback cb3 = &Wrap!((){});    // NG

This should be compiled. The lambda function (){} has no outer context access,
so it should not be treated as nested. But, it had been accidentally done.

As a conclusion, current compiler works as expected. This bug is already fixed.

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