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

Can't access element from array with named type #4388

Closed
philrz opened this issue Feb 17, 2023 · 1 comment · Fixed by #4391
Closed

Can't access element from array with named type #4388

philrz opened this issue Feb 17, 2023 · 1 comment · Fixed by #4391
Assignees
Labels
bug Something isn't working

Comments

@philrz
Copy link
Contributor

philrz commented Feb 17, 2023

Repro is with Zed commit 332fb2c.

This works:

$ zq -version
Version: v1.5.0-34-g332fb2cd

$ echo '["foo","bar"]' | zq 'yield this[0]' -
"foo"

But this does not:

$ echo '["foo","bar"](=baz)' | zq 'yield this[0]' -
error("missing")

@mccanne's take upon seeing this:

Probably the type check isn't looking under the named type.

@philrz philrz added the bug Something isn't working label Feb 17, 2023
mccanne added a commit that referenced this issue Feb 18, 2023
This commit fixes a bug where the index operator wasn't looking
under named types for arrays, sets, maps, and records.  The fix
is to simply call zed.TypeUnder for the type in question.

Closes #4388
mccanne added a commit that referenced this issue Feb 20, 2023
This commit fixes a bug where the index operator wasn't looking
under named types for arrays, sets, maps, and records.  The fix
is to simply call zed.TypeUnder for the type in question.

Closes #4388
@philrz
Copy link
Contributor Author

philrz commented Feb 21, 2023

Verified in Zed commit 6889ec5.

Now we can access the element from the array with the named type successfully.

$ zq -version
Version: v1.5.0-36-g6889ec58

$ echo '["foo","bar"](=baz)' | zq 'yield this[0]' -
"foo"

Thanks @mccanne!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants