void main() { int[256] data; foreach (ubyte i; 0 .. data.length) {} // OK foreach (ubyte i, x; data) {} // Error } test.d(4,5): Error: index type 'ubyte' cannot cover index range 0..256
Similar to Issue 1878. I think I've even seen this bug reported somewhere though.. And a similar thread from 2011: http://forum.dlang.org/thread/ik8tq5$1ma0$1@digitalmars.com
(In reply to comment #1) > Similar to Issue 1878. I think I've even seen this bug reported somewhere > though.. > > And a similar thread from 2011: > http://forum.dlang.org/thread/ik8tq5$1ma0$1@digitalmars.com But the since 1878 and year 2011 the foreach situation is changed. So I think it's a bug (or missed case) in the recent improvements of foreach.
@NilsLankila updated dlang/dmd pull request #11359 "fix issue 12504 - Wrong 'cannot cover index range' error message" fixing this issue: - fix issue 12504 - Wrong 'cannot cover index range' error message https://github.com/dlang/dmd/pull/11359
dlang/dmd pull request #11359 "fix issue 12504 - Wrong 'cannot cover index range' error message" was merged into stable: - 23693e8699a319e1175b6516df3f4c309561c3da by Nils Lankila: fix issue 12504 - Wrong 'cannot cover index range' error message https://github.com/dlang/dmd/pull/11359
dlang/dmd pull request #11366 "merge stable" was merged into master: - 432ee0093f812e33cbd6b77f2ae17fae254db5e0 by Nils Lankila: fix issue 12504 - Wrong 'cannot cover index range' error message https://github.com/dlang/dmd/pull/11366
dlang/dmd pull request #12668 "[dmd-cxx] Backport recent bug fixes for static foreach ICEs" was merged into dmd-cxx: - b826d9c9e4de188ffbbb2d9ee9b374b807bc4cdf by Nils Lankila: [dmd-cxx] fix issue 12504 - Wrong 'cannot cover index range' error message https://github.com/dlang/dmd/pull/12668