Bug 5965 – [2.053 beta] map rejects a predicate with anon-func and nested func
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-05-08T22:40:00Z
Last change time
2015-06-09T05:13:48Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2011-05-08T22:40:28Z
-----------------------------------
import std.algorithm;
void main()
{
int foo(int i) { return i; }
int[] arr;
auto x = map!( (int a){return foo(a);} )(arr);
}
-----------------------------------
That worked in 2.052, but fails to compile in 2.053 beta with the message:
test.d(8): Error: delegate std.algorithm.__dgliteral1 cannot access frame of
function test.main.__dgliteral1
I haven't checked to see if this is an issue with map or with using that func as a template argument.
Comment #1 by bugzilla — 2011-05-11T13:28:18Z
Reduced test case:
template mapx(fun...) if (fun.length >= 1)
{
int mapx(Range)(Range r)
{
return 1;
}
}
void test()
{
int foo(int i) { return i; }
int[] arr;
auto x = mapx!( function(int a){return foo(a);} )(arr);
}