www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1367] New: D 2.003 breaks foreach looping over delegate

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: thecybershadow 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.


-- 
Jul 23 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1367


thecybershadow gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |regression
            Summary|D 2.003 breaks foreach      |D 2.003 breaks foreach
                   |looping over delegate       |looping over delegate




-- 
Jul 23 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1367


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME





Works in 2.015


-- 
Jun 24 2008