Skip to content

Correct the lengths for the "get" shortcut container functions - #474

Merged
Licenser merged 2 commits into
simd-lite:mainfrom
ridiculousfish:fix-try-get-containers
Oct 3, 2026
Merged

Licenser merged 2 commits into
simd-lite:mainfrom
ridiculousfish:fix-try-get-containers

Conversation

@ridiculousfish

Copy link
Copy Markdown
Contributor

Containers in simd-json are represented via a header node, followed by the contained nodes. Thus the number of nodes should be one more than the length of the container.

This +1 was correctly applied in "get/try_get" path followed by as_array/as_object, but was missed in the typed shortcut functions such as "get_array" or "try_get_array." Thus "try_get" would return arrays and objects missing their last element; or an invalid object if the array was empty.

Correct this and add a test.

ridiculousfish and others added 2 commits August 15, 2026 13:16
Containers in simd-json are represented via a header node, followed
by the contained nodes. Thus the number of nodes should be one more than
the length of the container.

This +1 was correctly applied in "get/try_get" path followed by
as_array/as_object, but was missed in the typed shortcut functions such as
"get_array" or "try_get_array." Thus "try_get" would return arrays and
objects missing their last element; or an invalid object if the array
was empty.

Correct this and add a test.

@Licenser Licenser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@Licenser
Licenser enabled auto-merge (squash) October 3, 2026 17:59
@Licenser
Licenser merged commit 22609d9 into simd-lite:main Oct 3, 2026
29 checks passed
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

Successfully merging this pull request may close these issues.

2 participants