Skip to content
New issue

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

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

Already on GitHub? # to your account

1715 Drop array bound checking #1766

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaelhkay
Copy link
Contributor

Fix #1715

Drops array bound checking from array:get, arrays-as-functions, and array lookup. Returns () instead of an error FOAY0001 when the index is out of bounds. This brings arrays and maps into closer alignment.

Drops the $fallback argument of array:get()

Adds a new function array:get-if-present() which replicates the old behaviour of array:get().

Functions such as array:put, array:replace, array:insert-before, array:head, array:tail continue to perform bound checking.

@michaelhkay michaelhkay added XPath An issue related to XPath XQuery An issue related to XQuery XQFO An issue related to Functions and Operators Enhancement A change or improvement to an existing feature Reversion PR reverts spec to an earlier status quo Tests Needed Tests need to be written or merged labels Feb 5, 2025
@ChristianGruen
Copy link
Contributor

ChristianGruen commented Feb 5, 2025

Functions such as array:put, array:replace, array:insert-before, array:head, array:tail continue to perform bound checking.

To improve symmetry with sequences, I think we should get rid of the checks for all read function, including array:head and array:tail, to ensure that expressions like $array(1) and array:head($array) can be mutually rewritten (both by users and optimizers). But I agree it’s a good idea to keep the checks for updates.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Enhancement A change or improvement to an existing feature Reversion PR reverts spec to an earlier status quo Tests Needed Tests need to be written or merged XPath An issue related to XPath XQFO An issue related to Functions and Operators XQuery An issue related to XQuery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array Lookups: partial removal of out-of-bounds checks
2 participants