zed
zed copied to clipboard
map index selectors on this returns missing
If I do a map index selector on this I get a "missing" error:
$ echo '|{"one":1}|' | go run ./cmd/zq 'yield this["one"]' -
error("missing")
If the index selector is on a map inside an array, however this works:
$ echo '{a:|{"one":1}|}' | go run ./cmd/zq 'yield a["one"]' -
1
There appears to be something funny going on in the semantic pass. For yield this["one"] I get (note the lack of '[' operator):
{
"exprs": [
{
"kind": "This",
"path": [
"hi"
]
}
],
"kind": "Yield"
}
Since this one has been hanging out for a while, I just did a quick check and confirmed that it's still with us in current Zed.
$ zq -version
Version: v1.1.0-58-gd97c452a
$ echo '|{"one":1}|' | zq 'yield this["one"]' -
error("missing")
$ echo '{a:|{"one":1}|}' | zq 'yield a["one"]' -
1
#4132 fixed this. The command in the previous comment now works as expected.
$ zq -version
Version: v1.2.0-85-ge9624c3b
$ echo '|{"one":1}|' | go run ./cmd/zq 'yield this["one"]' -
1