Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline-record definitions are not scoped #91

Open
ranvis opened this issue Nov 10, 2023 · 0 comments
Open

inline-record definitions are not scoped #91

ranvis opened this issue Nov 10, 2023 · 0 comments

Comments

@ranvis
Copy link

ranvis commented Nov 10, 2023

The spec says that the inner inline-record tag should not influence the outside of containing record-definitions tag:

https://github.com/kriszyp/cbor-records/#inline-record

If a inline-record tag is used within a record-definitions tag/value, the scope of the defined record/tag is limited to inside that record-definitions tag.

So with the data: d9dffe8319e000826141616183d9e0008200d9dffe8319e000826142616281d9e0008201f6d9e0008202d9dffe8319e000826143616382d9e0008203d9dfff8419e000826149616902f6d9e0008204f6d9e0008205f6

57342([ /record-definitions/
  57344,
  ["A", "a"],
  [
    57344([ /record-reference/
      0,
      57342([ /record-definitions/
        57344,
        ["B", "b"],
        [
          57344([1, null]) /record-reference/
        ]
      ])
    ]),
    57344([ /record-reference/
      2,
      57342([ /record-definitions/
        57344,
        ["C", "c"],
        [
          57344([ /record-reference/
            3,
            57343([ /inline-record/
              57344,
              ["I", "i"],
              2,
              null
            ])
          ]),
          57344([4, null]) /record-reference/
        ]
      ])
    ]),
    57344([5, null]) /record-reference/
  ]
])

Decoder() decoded to the following structure:

[{"A":0,"a":[{"B":1,"b":null}]},{"B":2,"b":[{"C":3,"c":{"I":2,"i":null}},{"I":4,"i":null}]},{"I":5,"i":null}]

but I expect to be either:

[{"A":0,"a":[{"B":1,"b":null}]},{"B":2,"b":[{"C":3,"c":{"I":2,"i":null}},{"I":4,"i":null}]},{"B":5,"b":null}]

or if the scope of record-definition is also limited to itself (not sure from my reading, but the defined tag structures and the examples seem to imply it is self-contained):

[{"A":0,"a":[{"B":1,"b":null}]},{"A":2,"a":[{"C":3,"c":{"I":2,"i":null}},{"I":4,"i":null}]},{"A":5,"a":null}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant