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

Don't wrap negative indices twice (fix #2826) #2827

Closed
wants to merge 1 commit into from

Conversation

nicowilliams
Copy link
Contributor

@nicowilliams nicowilliams commented Aug 6, 2023

Resolves #2826

@@ -2004,3 +2004,9 @@ walk(1)
walk(select(IN({}, []) | not))
{"a":1,"b":[]}
{"a":1}

# Issue #2826
.[-5]
Copy link
Contributor

Choose a reason for hiding this comment

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

We can merge the test at L251 with the following query; [.[range(-4; 4)]].

@nicowilliams
Copy link
Contributor Author

But now:

./jq -cn '[0, 1, 2]|path(.[-5])'
[-2]

@itchyny
Copy link
Contributor

itchyny commented Aug 6, 2023

Can we just drop support of index wrapping for the coming release and consider how pick should work on arrays later?

src/execute.c Outdated Show resolved Hide resolved
@nicowilliams
Copy link
Contributor Author

Can we just drop support of index wrapping for the coming release and consider how pick should work on arrays later?

The current version of this PR does not break pick/1.

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.

Array indexing of negative indices wraps twice
3 participants