[Issue 5384] New: Rows foreach on alias-this matrix

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 28 02:23:01 PST 2010


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

           Summary: Rows foreach on alias-this matrix
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-12-28 02:20:57 PST ---
This deprecated D2 code works with DMD 2.051:


typedef int[1][1] Mat;
void main() {
    Mat m;
    foreach (row; m) {}
}


But this alternative:


struct Mat {
    int[1][1] a;
    alias a this;
}
void main() {
    Mat m;
    foreach (row; m) {} // line 7
}


DMD 2.051 prints:

test.d(7): Error: cannot infer type for row

This is something that I'd like to see work, so structs+alias this are better
usable as an alternative of typedef.

-- 
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