[Issue 24713] New: `to!string` and `format` don’t handle infinite ranges

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 21 13:09:02 UTC 2024


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

          Issue ID: 24713
           Summary: `to!string` and `format` don’t handle infinite ranges
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: ogion.art at gmail.com

It is desirable to be able to stringize all existing D types (with `noreturn`
being exception). Currently, this doesn’t even compile:
import std.range, std.conv;
void main() {
    auto s = 42.repeat.to!string;
}
> Error: none of the overloads of template `std.conv.toImpl` 
> are callable using argument types `!(string)(Repeat!int)`

And this compiles but gets stuck in an infinite loop:
import std.range, std.format;
void main() {
    auto s = format("%s", 42.repeat);
}

An infinite range could be denoted by printing its first three elements
followed by an ellipsis (in this case: "[42, 42, 42, ...]").

--


More information about the Digitalmars-d-bugs mailing list