www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: k.hara.pg gmail.com



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: -------
Feb 14 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12168


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



Fixed commit in git-head:
https://github.com/D-Programming-Language/phobos/commit/8a1fc1253ab71944a2d630e4872d745958b733f2

Pull request for 2.065 branch:
https://github.com/D-Programming-Language/phobos/pull/1939

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12168


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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