w3c / json-ld-api

JSON-LD 1.1 Processing Algorithms and API Specification
https://w3c.github.io/json-ld-api/
Other
76 stars 29 forks source link

Compaction of IRIs with "@list" @container for sets of @list #547

Open progval opened 2 years ago

progval commented 2 years ago

Compacting this document:

{
  "http://schema.org/prop": [
    {
      "@list": ["foo", "bar"]
    },
    {
      "@list": ["baz", "qux"]
    }
  ]
}

with this context:

{
  "prop": {
    "@id": "http://schema.org/prop",
    "@container": "@list"
  }
}

produces this new document:

{
  "@context": {
    "prop": {
      "@id": "http://schema.org/prop",
      "@container": "@list"
    }
  },
  "prop": [
    "baz",
    "qux"
  ]
}

which is missing the first of the two lists.

(Tested with the JSON-LD playground , PyLD, and the ruby-ld gem)

As far as I can tell, this is caused by step 12.8.7.3 of the compaction algorithm, which sets 'item active property' first to ["foo", "bar"] then to ["baz", "qux"] causing the first value to be overwritten, and lost from the compacted document.

Is this an expected consequence of the algorithm specification?

gkellogg commented 2 years ago

That is definitely not an expected result, and will require more investigation and addition tests. Thanks for reporting.

tchoutri commented 1 year ago

Hi, I'm in the process of writing a new JSON-LD implementation. Is this something that I should take into account when writing the compliance test suite?

gkellogg commented 1 year ago

@tchoutri great that you're working on an implementation! At some point, we should add you to the list on json-ld.org. Regarding this issue, it is considered an Erratum, which when resolved, becomes an official part of the spec, so it would make sense to consider it. Note that There are other raised Errata which still need consideration, as well as some Errata that haven't been incorporated into the spec and await a future publication, but should be considered by implementors in any case.

tchoutri commented 1 year ago

Thanks a lot @gkellogg for your reactivity. :)