Bug 12782 – Wrong foreach mutable index implicit conversion error

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-21T21:07:00Z
Last change time
2014-06-30T03:32:23Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-05-21T21:07:29Z
Apparently the bug fix of Issue 9570 is not able to handle this case, so this is a new enhancement request. I think this code should be accepted: void main() { ubyte[256] data; foreach (ubyte i, ref x; data) { i += 200; i = 200; x = i; } } With dmd 2.066alpha it gives: temp.d(3,5): Error: index type 'ubyte' cannot cover index range 0..256
Comment #1 by lio+bugzilla — 2014-06-30T03:32:23Z
*** This issue has been marked as a duplicate of issue 12685 ***