[Issue 13390] [REG2.066] std.range.cycle ctor fails when empty input passed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Aug 29 03:24:46 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13390

monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com

--- Comment #6 from monarchdodra at gmail.com ---
(In reply to drug007 from comment #5)
> I agree with clarity. But I'm not sure if cycle may be empty at all, that's
> the question, I guess...

I believe cycle should not be passed an empty range. Or to be more precise, the
underlying range may not at any point in time become empty.

The reasoning for this is that cycle is an infinite range, meaning it can be
*statically* verified as being not empty.

Now, it is always incorrect for phobos to produce a crash. At the very least,
an assert should be placed. Furthermore, I don't really believe that the
constructor should fail. Rather, the operations pop should error out, and the
operations front should index out of bounds.

And we should document the error. I'm on it.

--


More information about the Digitalmars-d-bugs mailing list