www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7944] New: popFront() cycles when the range is empty

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7944

           Summary: popFront() cycles when the range is empty
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: lovelydear mailmetrash.com



PDT ---
Original discussion:
http://forum.dlang.org/post/itrsidszogvnobzvlbwg forum.dlang.org

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 ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7944


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7944


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



iota should have an in-contract that asserts !empty.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7944




https://github.com/D-Programming-Language/phobos/pull/545

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7944




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


fix Issue 7944 - std.range.iota.popFront() cycles when the range is empty

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 22 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7944


Brad Anderson <eco gnuk.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 22 2012