Skip to content

Commit e2bd910

Browse files
committed
More
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 3e799de commit e2bd910

2 files changed

Lines changed: 662 additions & 0 deletions

File tree

src/output/output_jsonld.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,20 @@ auto resolve(const sourcemeta::core::JSON &instance,
512512
: "A JSON-LD predicate cannot be assigned to an array element");
513513
}
514514

515+
// A container member belongs to a collection, not a node, so it has no
516+
// parent to attach a predicate to
517+
if (!facts.edges.empty() && !pointer.empty()) {
518+
auto parent{pointer};
519+
parent.pop_back();
520+
const auto parent_facts{accumulator.find(parent)};
521+
if (parent_facts != accumulator.cend() &&
522+
parent_facts->second.container.has_value()) {
523+
return facet_error(
524+
pointer, sourcemeta::blaze::JSONLDFacet::Predicate,
525+
"A JSON-LD predicate cannot be assigned to a container member");
526+
}
527+
}
528+
515529
// A reverse predicate makes its value the subject, so the value must be a
516530
// node or an array of nodes. A literal cannot be a subject
517531
if (std::ranges::any_of(

0 commit comments

Comments
 (0)