[Issue 15884] Assigning char[] to std.json.JSONValue creates array, not string

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Apr 9 00:51:41 PDT 2016


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

b2.temp at gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp at gmx.com

--- Comment #2 from b2.temp at gmx.com ---
(In reply to Lionello Lunesu from comment #1)
> Ugh, I understand why it's the way it is.
> 
> Should we do .idup in JSONValue? Either way there's going to be an
> allocation, either for the JSONValue[] or for the string.
> 
> The repro might seem convoluted, but I ran into it like this: a method
> returns a char[], in order to give the caller full r/w control, which is
> what such a "toString" function is supposed to do. Using this return value
> (which thanks to "auto" is not obvious) in a JSONValue results in a less
> than ideal JSON.

I have tested a fix and calling idup doesn't break current tests, actually the
method that's involved to make it accepts char[] is a template and with
attribute inference there is no problem. It's always pure nothrow @safe, safe
is a new requirement on the master version of std.json.

--


More information about the Digitalmars-d-bugs mailing list