Bug 23243 – std.range.isInfinite should accept ranges with non-static empty methods

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-07-13T02:07:45Z
Last change time
2022-07-13T21:37:18Z
Assigned to
No Owner
Creator
Paul Backus
Blocks
23242

Comments

Comment #0 by snarwin+bugzilla — 2022-07-13T02:07:45Z
As of DMD 2.100.0, the following program fails to compile: --- import std.range.primitives; struct R { int front() { return 42; } bool empty() { return false; } void popFront() {} } static assert(isInputRange!R); // ok enum e = R().empty; // ok static assert(isInfinite!R); // fails --- Since R is an input range whose .empty property evaluates to false at compile time, it should be accepted as an infinite range. This issue blocks issue 23242.
Comment #1 by snarwin+bugzilla — 2022-07-13T21:37:18Z
On second thought, this is not possible, because (1) we cannot check the return value of .empty for all possible instances of R, and (2) even if .empty returns false for every instance tested, we can never be sure it will not return true for some other instance we did not test.