http://d.puremagic.com/issues/show_bug.cgi?id=3154
Summary: foreach corrupting data returned by ref functions.
Product: D
Version: 2.031
Platform: Other
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
void main()
{
auto test = Foo(3);
foreach (i; test.items) { }
}
struct Foo
{
struct Generator
{
int opApply(int delegate(ref long) dg)
{
const bak = this.foo.data; // control copy
int res;
for (long i=0; i < bak; i++)
{
assert (bak == this.foo.data, "this.foo changed?!");
res = dg(i);
if (res)
break;
}
return res;
}
Foo foo;
}
ref Generator items() // ref is important
{
return Generator(this); // Generator.foo = this
}
int data;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------