[Issue 11886] New: "cannot access frame" error on lambda in lambda
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 9 12:38:47 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11886
Summary: "cannot access frame" error on lambda in lambda
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: verylonglogin.reg at gmail.com
--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2014-01-10 00:38:44 MSK ---
This code should compile:
---
struct S(alias fun)
{ void sf() { fun(1); } }
void f(alias fun)()
{ fun(); }
void g(alias fun)()
{ auto s = S!fun(); } // line 8
void main()
{
int n;
f!(() => g!(b => n)())(); // line 13
}
---
main.d(13): Error: delegate main.main.__lambda1.__lambda1 cannot access frame
of function D main
main.d(13): Error: pure nested function '__lambda1' cannot access mutable data
'n'
main.d(8): instantiated from here: S!(__lambda1)
main.d(13): instantiated from here: g!((b) => n)
---
It worked with previous dmd. As a result dmd rejects now such previously
working code:
---
import std.algorithm, std.array;
auto makeInoutArray(alias func, T)(inout T[] src)
{
return cast(inout) func(cast(T[]) src).array();
}
void f(inout(int)[] iarr)
{
int n;
iarr.makeInoutArray!(arr => arr.map!(a => n)())();
}
---
Also dmd ICEs once while reducing this code to minimal testcase.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list