D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5384 - Rows foreach on alias-this matrix
Summary: Rows foreach on alias-this matrix
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-12-28 02:20 UTC by bearophile_hugs
Modified: 2012-05-30 21:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-12-28 02:20:57 UTC
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.
Comment 1 Kenji Hara 2012-05-30 21:40:03 UTC
Works in 2.060head.