Bug 5384 – Rows foreach on alias-this matrix

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-12-28T02:20:00Z
Last change time
2012-05-30T21:40:03Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-12-28T02:20:57Z
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 by k.hara.pg — 2012-05-30T21:40:03Z
Works in 2.060head.