[Issue 9150] New: Mismatching static array length should be detected in foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 13 07:21:20 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9150

           Summary: Mismatching static array length should be detected in
                    foreach
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-12-13 07:21:19 PST ---
>From the forum discussion:
http://forum.dlang.org/thread/mswgcdhrzcgcjavtqvog@forum.dlang.org?page=2#post-gdzjavizncygkbtftpnh:40forum.dlang.org

import std.stdio;

void main()
{
    int[3][2] matrix = [ [1,11,111], [2,22,222] ];

    foreach (int[5] row; matrix) //if int[3], there is no error.
    {
         foreach (x; row)
            write(x, "  ");

         writeln();
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list