www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23243] New: std.range.isInfinite should accept ranges with


          Issue ID: 23243
           Summary: std.range.isInfinite should accept ranges with
                    non-static empty methods
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          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.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.

Jul 12 2022