Bug 22608 – RandomAccessInfinite is not a valid random-access range
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-12-19T00:07:35Z
Last change time
2021-12-19T02:48:17Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2021-12-19T00:07:35Z
As of DMD 2.098.0, the following program fails to compile:
---
import std.range.primitives: isRandomAccessRange;
import std.range.interfaces: RandomAccessInfinite;
static assert(isRandomAccessRange!(RandomAccessInfinite!int));
---
The error message is:
---
bug.d(4): Error: static assert: `isRandomAccessRange!(RandomAccessInfinite!int)` is false
---
The failure occurs because `isInfinite!(RandomAccessInfinite!int)` evaluates to false, which happens because `RandomAccessInfinite!int.empty` cannot be evaluated at compile time.
Comment #1 by dlang-bot — 2021-12-19T00:42:24Z
@pbackus created dlang/phobos pull request #8338 "Fix issue 22608 - RandomAccessInfinite is not a valid random-access range" fixing this issue:
- Fix issue 22608 - RandomAccessInfinite is not a valid random-access range
Previously, isInfinite!(RandomAccessInfinite!T) would always evaluate to
false, because the 'empty' method inherited from InputRange could not be
evaluated at compile time. Since isRandomAccessRange!R requires
(isBidirectionalRange!R || isInfinite!R), this meant that
RandomAccessInfinite!T was not recognized as a random-access range.
https://github.com/dlang/phobos/pull/8338
Comment #2 by dlang-bot — 2021-12-19T02:48:17Z
dlang/phobos pull request #8338 "Fix issue 22608 - RandomAccessInfinite is not a valid random-access range" was merged into master:
- ce89dd9203f66588dea29e415840fd5659d79558 by Paul Backus:
Fix issue 22608 - RandomAccessInfinite is not a valid random-access range
Previously, isInfinite!(RandomAccessInfinite!T) would always evaluate to
false, because the 'empty' method inherited from InputRange could not be
evaluated at compile time. Since isRandomAccessRange!R requires
(isBidirectionalRange!R || isInfinite!R), this meant that
RandomAccessInfinite!T was not recognized as a random-access range.
https://github.com/dlang/phobos/pull/8338