www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21215] New: std.range.recurrence leads to an infinite loop

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

          Issue ID: 21215
           Summary: std.range.recurrence leads to an infinite loop
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: russel winder.org.uk

The following code leads to what seems to be an infinite loop when executed
using "dub test":
```
import std.range: dropExactly, recurrence;

ulong recurrency(immutable ulong n) {
    auto sequence = recurrence!((a, n) => a[n - 1] * n)(1UL);
    return sequence.dropExactly(n - 1).front;
}

version(unittest) {
    import unit_threaded;
}

 ("Check the base case")
unittest {
    recurrency(0).should == 1;
}

/*
 ("Check the property")
unittest {
    check!((ubyte n) => recurrency(n + 1) == (n + 1) * recurrency(n));
}
*/
```

--
Sep 02 2020