[Issue 1367] New: D 2.003 breaks foreach looping over delegate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 23 07:06:58 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1367
Summary: D 2.003 breaks foreach looping over delegate
Product: D
Version: 2.002
Platform: PC
URL: http://www.digitalmars.com/d/statement.html#ForeachState
ment
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: major
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: thecybershadow at gmail.com
Slightly modified example from
http://www.digitalmars.com/d/statement.html#ForeachStatement (to use a delegate
reference instead of opApply:
import std.stdio;
class Foo
{
uint array[2];
int looper(int delegate(ref uint) dg)
{
int result = 0;
for (int i = 0; i < array.length; i++)
{
result = dg(array[i]);
if (result)
break;
}
return result;
}
void run()
{
foreach (uint u; &looper)
writefln("%d", u);
}
}
void main()
{
Foo a = new Foo();
a.array[0] = 73;
a.array[1] = 82;
a.run();
}
Compiler prints:
foreach_delegate.d(22): Error: foreach: int function(int delegate(ref uint)
dg)* is not an aggregate type
This worked in DMD 2.002. opApply features seem unaffected.
--
More information about the Digitalmars-d-bugs
mailing list