Description
The following quote from the spec was brought up in a slack discussion.
From JSON Schema Core - Section 9.4.2
Similarly, a reference target under a known keyword, for which the value is known not to be a schema, results in undefined behavior in order to avoid burdening implementations with the need to detect such targets.
This brings into question a few of the tests in the suite. (There may be others. These are the ones I'm aware of.)
- https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft2020-12/id.json#L211-L261
- https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft2020-12/anchor.json#L84-L141
- https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft2020-12/unknownKeyword.json
These tests require that identifier declarations ($id
or $anchor
) in locations not known to be schemas are ignored. However, the quoted passage above would seem to indicate that the behavior is undefined in this situation and therefore we should not have tests that require a behavior in this case.
Full Disclosure: My implementation doesn't pass these tests and I don't intended to fix it. Although the removal of these tests is in my best interest, I'm only interesting in getting to the bottom of what is required by the spec. I've been content to skip those tests and if we decide they actually do belong in the suite, I'll just continue skipping them.