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

          Issue ID: 18560
           Summary: find on infinite ranges is broken
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: default_357-l...@yahoo.de

Consider:

assert(true.repeat.all != false);

We may expect this to hang indefinitely. We will certainly not expect it to
fail immediately!

What happens is this.

true.repeat is an infinite range. all searches for a place at which its
condition becomes false. For this, it employs find. Find uses "empty" to signal
success, ie.  it returns an empty range if the element was not found. However,
in this case find *cannot* return an empty range because the Repeat range type
can never be empty. It compiles anyways. This then leads to .empty concluding,
correctly, that find may never return an empty range, and immediately, without
evaluating its input range, returning false.

Either all must not be implemented on top of find, or find must be adjusted to
signal failure in some other way, possibly using a VariantN.

--

Reply via email to