← Back to index
|
Original Bugzilla link
Bug 7944 – std.range.iota.popFront() cycles when the range is empty
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-19T05:38:00Z
Last change time
2012-04-22T19:31:09Z
Assigned to
nobody
Creator
lovelydear
Comments
Comment #0
by lovelydear — 2012-04-19T05:38:23Z
Original discussion:
http://forum.dlang.org/post/
[email protected]
import std.range, std.stdio; void main() { auto r = iota(3); writeln(r.front, ", length: ", r.length, " empty ? ", r.empty); r.popFront(); writeln(r.front, ", length: ", r.length, " empty ? ", r.empty); r.popFront(); writeln(r.front, ", length: ", r.length, " empty ? ", r.empty); r.popFront(); writeln(r.front, ", length: ", r.length, " empty ? ", r.empty); r.popFront(); writeln(r.front, ", length: ", r.length, " empty ? ", r.empty); r.popFront(); } Returns: 0, length: 3 empty ? false 1, length: 2 empty ? false 2, length: 1 empty ? false 3, length: 0 empty ? true 4, length: 4294967295 empty ? false Shouldn't popFront() assert when r.empty == true ?
Comment #1
by hsteoh — 2012-04-19T07:34:28Z
iota should have an in-contract that asserts !empty.
Comment #2
by eco — 2012-04-19T19:04:44Z
https://github.com/D-Programming-Language/phobos/pull/545
Comment #3
by github-bugzilla — 2012-04-22T18:03:23Z
Commits pushed to master at
https://github.com/D-Programming-Language/phobos
https://github.com/D-Programming-Language/phobos/commit/028699fe6ca3defa598fef65ffd287e7e3626f72
fix Issue 7944 - std.range.iota.popFront() cycles when the range is empty Added !empty assertions to front, popFront, back, and popBack to the integer iota like some other ranges do. Also added the one that was missing to the floating point iota.
https://github.com/D-Programming-Language/phobos/commit/9233d3d20d18e2babf5395c4fb934c800b27ca7d
Merge pull request #545 from eco/iota-pop-empty fix Issue 7944 - std.range.iota.popFront() cycles when the range is empty