Bug 12504 – Wrong 'cannot cover index range' error message

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-04-01T15:40:09Z
Last change time
2021-06-11T17:17:48Z
Keywords
diagnostic, pull, rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-04-01T15:40:09Z
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
Comment #1 by andrej.mitrovich — 2014-04-02T04:02:59Z
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/[email protected]
Comment #2 by bearophile_hugs — 2014-04-02T04:17:59Z
(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/[email protected] 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.
Comment #3 by dlang-bot — 2020-07-01T20:12:26Z
@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
Comment #4 by dlang-bot — 2020-07-02T01:38:56Z
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
Comment #5 by dlang-bot — 2020-07-03T11:52:26Z
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
Comment #6 by dlang-bot — 2021-06-11T17:17:48Z
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