Ignore write to member

This commit is contained in:
Benoit Blanchon
2022-03-10 18:31:54 +01:00
parent 9d427982cc
commit a04c3f0189
2 changed files with 8 additions and 1 deletions

View File

@@ -72,4 +72,11 @@ TEST_CASE("Linked document") {
SECTION("get member") {
CHECK(variant["hello"].as<std::string>() == "world");
}
SECTION("set member") {
// The link is read-only; the following line should have no side effect
variant["tutu"] = "toto";
CHECK(doc1.as<std::string>() == "{\"hello\":\"world\"}");
}
}

View File

@@ -314,7 +314,7 @@ class VariantData {
TStoragePolicy storage_policy) {
if (isNull())
toObject();
if (!isObject())
if (!isObjectStrict())
return 0;
return _content.asCollection.getOrAddMember(key, pool, storage_policy);
}