[Issue 21215] New: std.range.recurrence leads to an infinite loop

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 2 11:15:08 UTC 2020


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 at puremagic.com
          Reporter: russel at 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));
}
*/
```

--


More information about the Digitalmars-d-bugs mailing list