D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12504 - Wrong 'cannot cover index range' error message
Summary: Wrong 'cannot cover index range' error message
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: diagnostic, pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2014-04-01 15:40 UTC by bearophile_hugs
Modified: 2021-06-11 17:17 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2014-04-01 15:40:09 UTC
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 Andrej Mitrovic 2014-04-02 04:02:59 UTC
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
Comment 2 bearophile_hugs 2014-04-02 04:17:59 UTC
(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.
Comment 3 Dlang Bot 2020-07-01 20:12:26 UTC
@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 Dlang Bot 2020-07-02 01:38:56 UTC
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 Dlang Bot 2020-07-03 11:52:26 UTC
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 Dlang Bot 2021-06-11 17:17:48 UTC
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