www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22255] New: JSONValue.opBinaryRight!"in" is const

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

          Issue ID: 22255
           Summary: JSONValue.opBinaryRight!"in" is const
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: giacomo.ratto protonmail.com

The following code fails to compile:

JSONValue j = [ "foo": "bar" ];
if (JSONValue* f = "foo" in j) // Error: cannot convert `const(JSONValue)*` to
`JSONValue*`
        *f = "baz";

making the method inout would solve the problem:
https://github.com/dlang/phobos/pull/8218

--
Aug 30 2021