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

Playground does not give expected result for expansion test c037 #568

Open zoggy opened 1 year ago

zoggy commented 1 year ago

Hi,

from expansion algorithm, I don't understand how nesting is supposed to work, especially when step 14.2.2 specifies to "Recursively repeat steps 13 and 14 using nested value for element", but steps 13 and 14 do not modify the active context, so nested values are expanded using the current active context, not the context associated to the nesting key.

I must precise that I'm implementing in a functional language, and it it not clear to me from the wording of the algorithm if active context is passed by reference along recursive calls. By now I assume that it is not the case but I way be wrong. It may be useful to indicate for each algorithm which arguments are passed by rerefence.

zoggy commented 1 year ago

Well,in fact it seems that either expansion test c037 is wrong, or jsonld.js implementation is wrong.

Input of c037 is

{
  "@context": {
    "@version": 1.1,
    "@vocab": "http://example.org/",
    "nest": {
      "@id": "@nest",
      "@context": {
        "@vocab": "http://example.org/nest/"
      }
    }
  },
  "nest": {
    "property": "should be in /nest"
  }
}

Expected output of c037 output is:

[{
  "http://example.org/nest/property": [{"@value": "should be in /nest"}]
}]

But JSON-LD Playground expands input to:

[
  {
    "http://example.org/property": [
      {
        "@value": "should be in /nest"
      }
    ]
  }
]

My implementation gives the same result as the playground, but this is not the expected result. Who is right ?

zoggy commented 1 year ago

Same for expansion test c038.

gkellogg commented 1 year ago

Might be an issue for jsonld.js. @davidlehn?

davidlehn commented 1 year ago

Looks like those tests are not passing in jsonld.js right now and are currently marked to be skipped. I don't recall the specific reasons why. Needs someone to look into what the fix should be. https://github.com/digitalbazaar/jsonld.js/blob/main/tests/test.js#L174