[Issue 4312] std.traits.ReturnType no longer accepts function literals
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 26 23:45:56 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4312
kennytm at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kennytm at gmail.com
--- Comment #4 from kennytm at gmail.com 2011-05-26 23:41:38 PDT ---
(In reply to comment #3)
> I can confirm that non-nested function literals now compile. (i.e. the original
> bug report) But nested function literals don't compile (DMD 2.053):
>
> void main(string[] args) {
> int b;
> writeln( (ReturnType!( function(int a){return a+b;} )).stringof );
> }
>
> Error: function hello.main.__funcliteral1 cannot access frame of function D
> main
>
> Not too sure if this is a separate issue or not.
This is expected. A function literal cannot form a closure. You need a
delegate.
--------------------------
void main() {
int b;
auto c = function(int a){return a+b;};
}
--------------------------
x.d(6): Error: function x.main.__funcliteral1 cannot access frame of function D
main
--------------------------
--
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