[Issue 12168] New: [REG2.065a] Add ref to array() and object() of JSONValue getters to add new element

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 14 23:22:09 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12168

           Summary: [REG2.065a] Add ref to array() and object() of
                    JSONValue getters to add new element
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2014-02-14 23:22:07 PST ---
In 2.064, JSONValue.array and JSONValue.object were instance fields.
But they are changed to getter functions, so directly appending values is
disallowed.

In git-head the issue is already fixed and appending is re-allowed..
https://github.com/D-Programming-Language/phobos/pull/1916

But still the problem is in 2.065-beta(1,2,3).
So I file the issue as a regression.

Test case:

void main()
{
    import std.json, std.conv;

    static if (__VERSION__ == 2064)
    {
        JSONValue vn = {integer:10};
        JSONValue jarr = {array:[vn]};
    }
    else
        JSONValue jarr = JSONValue([10]);
    foreach (i; 0..9)
    {
        static if (__VERSION__ == 2064)
            JSONValue v = {integer:i};
        else
            JSONValue v = JSONValue(i);

        jarr.array ~= v;
        // --> 2.065-beta: jarr.array() is not an lvalue
    }
    assert(jarr.array.length == 10);

    static if (__VERSION__ == 2064)
    {
        JSONValue vs = {str:"value"};
        JSONValue jobj = {object:["key" : vs]};
    }
    else
        JSONValue jobj = JSONValue(["key" : JSONValue("value")]);
    foreach (i; 0..9)
    {
        static if (__VERSION__ == 2064)
            JSONValue v = {str:text("value", i)};
        else
            JSONValue v = JSONValue(text("value", i));

        jobj.object[text("key", i)] = v;
        // --> 2.065-beta: jobj.object() is not an lvalue
    }
    assert(jobj.object.length == 10);
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list