You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, ...]").
The text was updated successfully, but these errors were encountered:
We've discussed this in PR #10660 and the consensus is that attempting to convert an infinite range to a string should result in a compile-time error, ideally with a meaningful error message.
So, the correct fix for this would be to do the following:
Improve the error message produced by to!string when attempting to convert an infinite range to a string.
Fix format so that it gives an error at compile time instead of getting stuck in an infinite loop when attempting to format an infinite range.
ogion.art reported this on 2024-08-21T13:09:02Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=24713
Description
The text was updated successfully, but these errors were encountered: