digitalmars.D.bugs - [Issue 19256] New: std.json: JSONValue allows violating constness
- d-bugmail puremagic.com (26/26) Sep 21 2018 https://issues.dlang.org/show_bug.cgi?id=19256
https://issues.dlang.org/show_bug.cgi?id=19256 Issue ID: 19256 Summary: std.json: JSONValue allows violating constness Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: default_357-line yahoo.de Consider the following code: import std.json; safe unittest { const JSONValue innerObj = JSONValue(["foo": JSONValue(1)]); assert(innerObj["foo"] == JSONValue(1)); // Why can I do this?? JSONValue value = innerObj; value["foo"] = JSONValue(2); assert(innerObj["foo"] == JSONValue(1)); } innerObj is changed, even though we access it through a const variable. This should not be allowed. --
Sep 21 2018