Bug 16246 – cannot call iota with 3 [u]bytes or 3 [u]shorts

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-07T08:00:11Z
Last change time
2018-01-05T13:28:46Z
Keywords
pull
Assigned to
No Owner
Creator
Eyal

Comments

Comment #0 by eyal — 2016-07-07T08:00:11Z
void main() { import std.range:iota; ushort start = 0, end = 10, step = 2; foreach(i; iota(start, end, step)) {} } Fails to build.
Comment #1 by schveiguy — 2016-07-07T12:53:45Z
I looked at the errors: /Users/steves/.dvm/compilers/dmd-2.071.1/osx/bin/../../src/phobos/std/range/package.d(4751): Error: cannot implicitly convert expression (cast(int)pastLast - 1) of type int to ushort /Users/steves/.dvm/compilers/dmd-2.071.1/osx/bin/../../src/phobos/std/range/package.d(4756): Error: cannot implicitly convert expression (cast(int)pastLast + 1) of type int to ushort /Users/steves/.dvm/compilers/dmd-2.071.1/osx/bin/../../src/phobos/std/range/package.d(4773): Error: cannot implicitly convert expression (cast(int)this.pastLast - cast(int)this.step) of type int to inout(ushort) We are just adding/subtracting 1 or step in each of these. Just cast to the correct type, should be sufficient. Alternatively, you can use += or -= instead. May need to `static if` this fix for only builtin types, as custom types probably already handle the operations correctly, and we don't want to mess with that.
Comment #2 by andrei — 2017-05-14T12:22:53Z
Comment #3 by schveiguy — 2017-05-14T13:29:26Z
Not fixed until the PR is merged. dlang-bot will do it automatically.
Comment #4 by andrei — 2017-05-14T13:56:11Z
(In reply to Steven Schveighoffer from comment #3) > Not fixed until the PR is merged. dlang-bot will do it automatically. Cool, thx.
Comment #5 by schveiguy — 2017-05-14T23:14:40Z
*** Issue 15717 has been marked as a duplicate of this issue. ***
Comment #6 by github-bugzilla — 2017-05-15T00:59:44Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6ff81f14057530484249dd4055e19c996b0485a7 Fix issue 16246 - cannot call iota with 3 [u]bytes or 3 [u]shorts https://github.com/dlang/phobos/commit/79edc62e8ff6ed5292fbc40e09cd944fb436740a Merge pull request #5391 from andralex/16246 Fix issue 16246 - cannot call iota with 3 [u]bytes or 3 [u]shorts merged-on-behalf-of: Andrei Alexandrescu <[email protected]>
Comment #7 by github-bugzilla — 2017-06-17T11:34:46Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6ff81f14057530484249dd4055e19c996b0485a7 Fix issue 16246 - cannot call iota with 3 [u]bytes or 3 [u]shorts https://github.com/dlang/phobos/commit/79edc62e8ff6ed5292fbc40e09cd944fb436740a Merge pull request #5391 from andralex/16246
Comment #8 by github-bugzilla — 2018-01-05T13:28:46Z
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6ff81f14057530484249dd4055e19c996b0485a7 Fix issue 16246 - cannot call iota with 3 [u]bytes or 3 [u]shorts https://github.com/dlang/phobos/commit/79edc62e8ff6ed5292fbc40e09cd944fb436740a Merge pull request #5391 from andralex/16246