www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7738] New: Can't iterate a std.typecons.Typedef!(int[]) with foreach

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7738

           Summary: Can't iterate a std.typecons.Typedef!(int[]) with
                    foreach
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This compiles in DMD 2.059head:

alias int[] MyArray;
void main() {
    MyArray arr;
    foreach (i, item; arr) {}
}



This doesn't compile:

import std.typecons: Typedef;
alias Typedef!(int[]) MyArray;
void main() {
    MyArray arr;
    foreach (i, item; arr) {}
}

DMD 2.059head gives the error:

test.d(5): Error: invalid foreach aggregate arr


This simpler code gives the same error:

import std.typecons: Typedef;
alias Typedef!(int[]) MyArray;
void main() {
    MyArray arr;
    foreach (item; arr) {}
}


My main use cases for typedef are with arrays. So this problem makes
std.typecons.Typedef not much useful.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 19 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7738


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |WORKSFORME



14:08:09 PST ---
Works in 2.061

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7738





 Works in 2.061
A step forward for D language. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2013