[Issue 18790] can't put a const(char)[] into a char[]
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 21 23:20:13 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18790
Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |issues.dlang at jmdavisProg.co
| |m
Severity|normal |enhancement
--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Steven Schveighoffer from comment #0)
> The most basic string output range is char[]. Why can't I put a string in
> there?
Because char[] isn't an output range at all. isOutputRange!(char[], char) is
false. No array of char or wchar is an output range, as annoying as that may
be.
> The answer to my question is (as usual) auto-decoding. ugh.
Yes. And I don't know what the solution to that is, not without actually
getting rid of autodecoding, and I don't see how we can do that without being
willing to silently break a lot of code or doing something like make it so that
strings aren't ranges anymore (at least temporarily), both of which would be
_really_ disruptive.
> At the very least, the message should be clearer (obviously, we can put a
> string into a char[]!).
Well, actually, you _can't_ "put" string into a char[]. put doesn't work with
char[]. So, it's perfectly accurate. However, it's also a terrible message,
because all it's saying is that put doesn't compile with the given arguments,
not why. It really should say something more like "char[] isn't an output
range", and if there's a similar static assert for types that _are_ output
ranges but don't accept the given type, then they should have a different
message for that that makes it clear that the output range doesn't have a put
method that accepts the given argument type, and std.range.primitives.put can't
convert it for you.
--
More information about the Digitalmars-d-bugs
mailing list