Yes it works in that way. I had to change it in a lot of source files. It worked fine for months as online webservice used by thousands users and never crashed :)

With last changes to code (a db connection preference - not relevant to std.json) it starts failing every time.



On Wednesday, 6 February 2013 at 09:41:28 UTC, Stephan wrote:
On Monday, 4 February 2013 at 10:04:10 UTC, Andrea Fontana wrote:
This code was working some months ago:

import std.json;
JSONValue total;
total.type = JSON_TYPE.OBJECT;
total["results"].type = JSON_TYPE.OBJECT;


Now, last line gives me a segmentation fault. What's wrong with this code?

Here is a full test case. I don't want to submit it to Bugzilla yet, since I don't know whether it's intended behaviour or a bug. I have a slight feeling that this is NOT a bug. Somehow, in the first case a reference to an invalid struct is returned by json["hello"] and attempted to be overridden by a new JSONValue. In the second case, no reference is generated, instead a simple struct copy (a blit) is invoked, which works. Can someone explain this more correctly?

This program crashes (tested on dmd 2.061)
import std.json;
void main() {
  JSONValue json;
  json.type = JSON_TYPE.OBJECT;
  json["hello"] = JSONValue();
}

This program works fine:
import std.json;
void main() {
  JSONValue json;
  json.type = JSON_TYPE.OBJECT;
  json.object["hello"] = JSONValue();
}

Reply via email to