www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23242] New: InputRangeObject derived from

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

          Issue ID: 23242
           Summary: InputRangeObject derived from RandomAccessInfinite is
                    not a random-access range
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

As of DMD 2.100.0, the following program fails to compile:

---
import std.range;

void main()
{
    auto r = repeat(0).inputRangeObject;
    static assert(is(typeof(r) : RandomAccessInfinite!int)); // ok
    static assert(isRandomAccessRange!(typeof(r))); // fails
}
---

This happens because the InputRangeObject r does not have an .empty property
that evaluates to false at compile time, as required by
std.range.primitives.isInfinite.

See also issue 22608.

--
Jul 12 2022